I am using my quo_custname that is bind in my dropdownlist and use its value to Insert my data.So whenever I choose a value on my dropdownlist quo_name change but whenever I use my class for mysql Insertion.
I get this error
Additional information: Incorrect syntax near the keyword 'WHERE'.
Here is my code:
private void AddToQuotation()
{
con.Open();
cmd = new SqlCommand(@"INSERT INTO JobQuotations
(quo_disount,quo_unitPrice,quo_TotalAmount,quo_finishing)
VALUES
('@discount','@unitPrice','@totalAmount'
,'@finishing')
WHERE quo_custname = '@customername'
AND quo_verified = 'no'",con);
cmd.Parameters.AddWithValue("@customername",DropDownList3.SelectedItem.Value.ToString());
cmd.Parameters.AddWithValue("@discount",txtDisc.Text);
cmd.Parameters.AddWithValue("@unitPrice",txtUnitPrice.Text);
cmd.Parameters.AddWithValue("@totalAmount",lblTotalAmount.Text);
cmd.ExecuteNonQuery();
con.Close();
string script = "alert(\"Functioning!\");";
ScriptManager.RegisterStartupScript(this, GetType(),
"ServerControlScript", script, true);
}
*Bonus question also how could I using try and catch so that it wouldn't break my program and get the SqlException name and the Additional information in my script to popup a message.
@customernameinstead of'@customername'otherwise they will be recognized as string