total_seat = tot_seat.ExecuteScalar().ToString();
An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: Incorrect syntax near '1'.
What I have tried:
protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)
{
string w = Request.QueryString["q"];
total_cost = Convert.ToInt16(lbl_total_price.Text);
if (DropDownList1.SelectedValue == "1")
ticket_price = 130;
if (DropDownList1.SelectedValue == "2")
ticket_price = 110;
int s = Convert.ToInt16(DropDownList2.SelectedValue);
ticket_price = ticket_price * s;
txt_ticket_price.Text = ticket_price.ToString(); ;
txt_ticket_price.Enabled = false;
txt_combo_price.Text = total_cost.ToString();
txt_combo_price.Enabled = false;
txt_service_fees.Text = "10";
txt_service_fees.Enabled = false;
int net_payable;
net_payable = total_cost + ticket_price;
txt_net_payable.Text = net_payable.ToString();
txt_net_payable.Enabled = false;
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["dataConnectionString"].ConnectionString);
con.Open();
int a = Convert.ToInt16(txt_combo_price.Text);
int b = Convert.ToInt16(txt_ticket_price.Text);
string c = Convert.ToString(DropDownList1.SelectedItem);
int d = Convert.ToInt16(DropDownList2.SelectedValue);
int f = Convert.ToInt16(txt_net_payable.Text);
string seat_typ = "1", total_seat = "1";
if (DropDownList1.SelectedValue == "1")
{
seat_typ = "select no_of_seats from booking where type='gold'";
total_seat = "select gold from seats";
}
if (DropDownList1.SelectedValue == "2")
{
seat_typ = "select no_of_seats from booking where type='silver'";
total_seat = "select silver from seats";
}
SqlCommand seat = new SqlCommand(seat_typ, con);
SqlCommand tot_seat = new SqlCommand(total_seat, con);
total_seat = tot_seat.ExecuteScalar().ToString();
int t_seat = Convert.ToInt16(total_seat);
string seat_info = seat.ExecuteScalar().ToString();
int drp = DropDownList2.SelectedIndex;
int s_info = Convert.ToInt16(seat_info);
s_info = s_info + drp;
string sql, no_of_seats, type;
if (s_info < t_seat)
{
if (DropDownList1.SelectedValue == "1")
{
type = "update booking set no_of_seats='" + s_info + "',seat_booked_now='gold' where type='gold'";
sql = "insert into booking_info (username,gold_booked,combo_cost,ticket_cost,seat_type,no_of_seats,net_payable) values('" + w + "','" + s_info + "','" + a + "','" + b + "','" + c + "','" + d + "','" + f + "')";
}
else
{
type = "update booking set no_of_seats='" + s_info + "',seat_booked_now='silver' where type='silver'";
sql = "insert into booking_info (username,silver_booked,combo_cost,ticket_cost,seat_type,no_of_seats,net_payable) values('" + w + "','" + s_info + "','" + a + "','" + b + "','" + c + "','" + d + "','" + f + "')";
}
SqlCommand typ = new SqlCommand(type, con);
SqlCommand cmd = new SqlCommand(sql, con);
typ.ExecuteNonQuery();
cmd.ExecuteNonQuery();
}
else
Response.Write("not enough seats available");
}
this is the code..please help me