none
Stored Procedure in visual basic 2010

    Question

  • Hi Good People

    I have a Problem Creating a stored Procedure I keep getting an Error Message saying

    Incorrect syntax near '@BFDateTimePicker',
    Must declare the scalar variable "@BfDateTimePicker",
    Must declare the scalar variable "@Date_Time_Taken".

    Can someone please tell me what is wrong with my code. I have looked at video and other code to no avail

    Kind Regards

    Gary

     

    CREATE PROCEDURE dbo.InsertBooking
    	(
    	@JobID int Output
    	@BFDateTimePicker Date Output
    	@TimeMaskedTexBox Time
    	@Account_Name varchar(50)
    	@Vehicle_Type varchar(50)
    	@Name_Number Varchar(50)
    	@Destination_From Varchar(50)
    	@Number_Name Varchar(50)
    	@Destination_To Varchar(50)
    	@Destination_Via Varchar(50)
    	@Fare money
    	@Extra_Fare money
    	@Total_Fare money
    	@Driver Varchar(50)
    	@Controller Varchar(50)
    	@Week_Number Varchar(50)
    	@Date_Time_Taken Timestamp
    	@Notes Text
    	)
    	INSERT INTO Booking
    	(JobID, BFDateTimePicker, TimeMaskedTextBox, Account_Name, Vehicle_Type, Name_Number, DestinationFrom, Number_Name, Destination_To, Destination_Via, Fare, Extra_fare, Total_Fare, Driver, Controller, Week_Number, Date_Time_Taken, Notes)
    		Values 
    		(@JobID, @BFDateTimePicker, @TimeMaskedTextBox, @Account_Name, @Vehicle_Type, @Name_Number, @DestinationFrom, @Number_Name, @Destination_To, @Destination_Via, @Fare, @Extra_fare, @Total_Fare, @Driver, @Controller, @Week_Number, @Date_Time_Taken, @Notes);
    
    IF @@ROWCOUNT>0 And @@ERROR>=0
    Select @JobID = JobID,
    @Date_Time_Taken = Date_Time_Taken
    From Booking
    Where (JobID = SCOPE_IDENTITY()); 
    
    
     


    Gary Simpson
    Sunday, May 22, 2011 6:08 PM

Answers

  • I think you need to put comma's after all of your variables in the first set of brackets, so it would look like the following:

    CREATE PROCEDURE dbo.InsertBooking
    	(
    	@JobID int Output,
    	@BFDateTimePicker Date Output,
    	@TimeMaskedTexBox Time,
    	@Account_Name varchar(50),
    	@Vehicle_Type varchar(50),
    	@Name_Number Varchar(50),
    	@Destination_From Varchar(50),
    	@Number_Name Varchar(50),
    	@Destination_To Varchar(50),
    	@Destination_Via Varchar(50),
    	@Fare money,
    	@Extra_Fare money,
    	@Total_Fare money,
    	@Driver Varchar(50),
    	@Controller Varchar(50),
    	@Week_Number Varchar(50),
    	@Date_Time_Taken Timestamp,
    	@Notes Text
    	)
    	INSERT INTO Booking
    	(JobID, BFDateTimePicker, TimeMaskedTextBox, Account_Name, Vehicle_Type, Name_Number, DestinationFrom, Number_Name, Destination_To, Destination_Via, Fare, Extra_fare, Total_Fare, Driver, Controller, Week_Number, Date_Time_Taken, Notes)
    		Values 
    		(@JobID, @BFDateTimePicker, @TimeMaskedTextBox, @Account_Name, @Vehicle_Type, @Name_Number, @DestinationFrom, @Number_Name, @Destination_To, @Destination_Via, @Fare, @Extra_fare, @Total_Fare, @Driver, @Controller, @Week_Number, @Date_Time_Taken, @Notes);
    
    IF @@ROWCOUNT>0 And @@ERROR>=0
    Select @JobID = JobID,
    @Date_Time_Taken = Date_Time_Taken
    From Booking
    Where (JobID = SCOPE_IDENTITY()); 

    You've always got to put a comma after these, otherwise the program wont know the difference between your variables. I'm not too sure if there is anything else wrong though, let me know?

    • Marked as answer by Gary Simpson Wednesday, May 25, 2011 12:56 AM
    Monday, May 23, 2011 3:19 AM

All replies

  • I think you need to put comma's after all of your variables in the first set of brackets, so it would look like the following:

    CREATE PROCEDURE dbo.InsertBooking
    	(
    	@JobID int Output,
    	@BFDateTimePicker Date Output,
    	@TimeMaskedTexBox Time,
    	@Account_Name varchar(50),
    	@Vehicle_Type varchar(50),
    	@Name_Number Varchar(50),
    	@Destination_From Varchar(50),
    	@Number_Name Varchar(50),
    	@Destination_To Varchar(50),
    	@Destination_Via Varchar(50),
    	@Fare money,
    	@Extra_Fare money,
    	@Total_Fare money,
    	@Driver Varchar(50),
    	@Controller Varchar(50),
    	@Week_Number Varchar(50),
    	@Date_Time_Taken Timestamp,
    	@Notes Text
    	)
    	INSERT INTO Booking
    	(JobID, BFDateTimePicker, TimeMaskedTextBox, Account_Name, Vehicle_Type, Name_Number, DestinationFrom, Number_Name, Destination_To, Destination_Via, Fare, Extra_fare, Total_Fare, Driver, Controller, Week_Number, Date_Time_Taken, Notes)
    		Values 
    		(@JobID, @BFDateTimePicker, @TimeMaskedTextBox, @Account_Name, @Vehicle_Type, @Name_Number, @DestinationFrom, @Number_Name, @Destination_To, @Destination_Via, @Fare, @Extra_fare, @Total_Fare, @Driver, @Controller, @Week_Number, @Date_Time_Taken, @Notes);
    
    IF @@ROWCOUNT>0 And @@ERROR>=0
    Select @JobID = JobID,
    @Date_Time_Taken = Date_Time_Taken
    From Booking
    Where (JobID = SCOPE_IDENTITY()); 

    You've always got to put a comma after these, otherwise the program wont know the difference between your variables. I'm not too sure if there is anything else wrong though, let me know?

    • Marked as answer by Gary Simpson Wednesday, May 25, 2011 12:56 AM
    Monday, May 23, 2011 3:19 AM
  • Gary,

    That you type in your code using a keyboard makes your question not a keyboard question.

    There is nothing VB in your question and therefore in my idea very off topic.

    Try the very active sql transact forum for your questions.

    http://social.msdn.microsoft.com/Forums/en-US/transactsql/threads


    Success
    Cor
    Monday, May 23, 2011 4:28 AM