A simple update operation is throwing an error like “incorrect syntax near ‘(‘”. My code is below.
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
con.Open();
string insCmd = "update Reg set (DateOfBirth,Experience)=@DateOfBirth,@Experience where UserName='"+Label3.Text+"'";
SqlCommand insertUser = new SqlCommand(insCmd, con);
insertUser.Parameters.AddWithValue("@Experience",TextBoxex.Text);
insertUser.Parameters.AddWithValue("@DateOfBirth",TextBoxdob.Text);
try
{
insertUser.ExecuteNonQuery();
con.Close();
Response.Redirect("Admin.aspx");
}
Remove the bracket from column name around
Setlike this: