Nwenar Ismail

Nwenar Ismail

  • NA
  • 83
  • 5.3k

Incorrect syntax for Set

May 3 2021 4:03 AM
Hello Mates I have a database project. I have created a button to update Data From my database so Whenever I try to update or test the Button which will do the update It says incorrect syntax near Set
So I will Write My Codes for updating
Thank You Guys
I got the code fromC-SharpCorner 
here is the link   Edit_Update Data From a Database in Windows Forms (c-sharpcorner.com) 
string str = "server = ADAM\\SQLEXPRESS;; Initial Catalog = GYM; Integrated security=true";
SqlConnection con = new SqlConnection(str);
/* ///// The Error is Coming from This LINE //// */
String query = "Update Set First_Name = '" + this.First_Name.Text + "', Second_Name= '" + this.Second_Name.Text + "',Last_Name= '" + this.Last_Name.Text + "',Age ='"+this.Age_Value.Value +"' where ID= '" + this.ID.Text + "' ";
SqlCommand cmd = new SqlCommand(query, con);
SqlDataReader dbr;
try
{
con.Open();
dbr = cmd.ExecuteReader();
MessageBox.Show("Updated data");
while (dbr.Read())
{
}
}
catch (Exception es)
{
MessageBox.Show(es.Message);
}

Answers (2)