Click here to Skip to main content
16,021,181 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
CREATE PROCEDURE dbo.usp_booking_insert
	@user_id int,
	@journey_place varchar(50),
	@pickup_address varchar(250),
	@return_address varchar(250),
	@service_id int,
	@vehicle_id int,
	@mode_of_payment varchar(50),
	@status varchar(5),
	@starting_km decimal(15,4),
	@ending_km decimal(15,4),
	@booking_date datetime

	AS
		Begin

		Declare @uid int
		if(@uid = 0)
		Begin
		set uid = (select max(user_id) from registration)
		End

		Else
		Begin
		set uid = @user_id
		End

		insert into booking (user_id,journey_place,pickup_date,pickup_address,return_date,return_address,service_id,vehicle_id,mode_of_payment,status,starting_km,ending_km,booking_date)
		 values (@uid,@journey_place,getdate(),@pickup_address,getdate(),@return_address,@service_id,@vehicle_id,@mode_of_payment,'true',0,0,@booking_date)

		End




there is an error in dis store procedure of "incorrect syntax near '='"
Posted
Updated 16-Mar-13 7:33am
v3

In addition to the above solution posted .. I would suggest you to change this line of code
SQL
set uid = (select max(user_id) from registration)

should be changed to
SQL
select @uid=max(user_id) from registration
 
Share this answer
 
Comments
Member 9671810 17-Mar-13 1:59am    
hey,
can you tell me how can i get date from the txtbox using getdate(),
as i have hot declared it..in store procedure.

cmd.Parameters.AddWithValue("@",);

what should i write over here..?
First of all, you are using SET[^] not with correct syntax, you missed the @: set @uid =.
BTW: what is the meaning to test the variable value right after declaring it?
 
Share this answer
 
Comments
Member 9671810 17-Mar-13 2:00am    
thanx....

bt can you tell me how can i get date from the txtbox using getdate(),
as i have hot declared it..in store procedure.

cmd.Parameters.AddWithValue("@",);

what should i write over here..?
bbirajdar 17-Mar-13 2:38am    
getdate() is a sql function to get current date.

To get the value from a textbox in asp.net you need to use

string dtStartDate=txtStartDate.Text.Trim()
Member 9671810 17-Mar-13 3:33am    
bt what should i pass in parameters...?

and i only want to use getdate()
Zoltán Zörgő 17-Mar-13 3:36am    
You wrote: "get date from the txtbox using getdate()". Well, you either use getdate and you get current date, or you get user input from a textbox and you need to pass it as parameter. These two have nothing in common.

BTW: you have posted it as reply to my answer, but aspnet_regiis -i wrote those to you.
Member 9671810 17-Mar-13 3:39am    
cmd.CommandText = "usp_booking_insert";
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@user_id", ddluname.SelectedValue);
cmd.Parameters.AddWithValue("@journey_place", txtjplace.Text);
cmd.Parameters.AddWithValue("getdate()", txtpickup_calenderri.Text);
cmd.Parameters.AddWithValue("@pickup_address", txtpickup_address.Text);
cmd.Parameters.AddWithValue("getdate()", txtreturndate.Text);
cmd.Parameters.AddWithValue("@return_address", txtreturn_address.Text);
cmd.Parameters.AddWithValue("@service_id", ddlsname.SelectedValue);
cmd.Parameters.AddWithValue("@vehicle_id", ddlvehicles.SelectedValue);
cmd.Parameters.AddWithValue("@mode_of_payment", rdbtnpayment.SelectedValue);
cmd.Parameters.AddWithValue("@booking_date", System.DateTime.Now.ToString());

dis is my code.. now what should i do?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900