Carl Nepomuceno
Carl Nepomuceno

Reputation: 1

Exception thrown: 'System.Data.SqlClient.SqlException' in System.Data.dll Additional information: Incorrect syntax near the keyword 'Table'

My code generates the following error:

An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll
Additional information:
Incorrect syntax near ')'.

My code is:

conn.Open();

SqlDataAdapter sda = new SqlDataAdapter("Update [Table] Set [Name]='" + textBox2.Text + "',[Course]='" + comboBox1.Text + "',[YearSection]='" + textBox3.Text + "' Where [Id]='"+textBox1.Text+"')", conn);

sda.SelectCommand.ExecuteNonQuery();
conn.Close();
MessageBox.Show("Updated Successfully !!!");

Can someone help me understand why this doesn't work.

Upvotes: 0

Views: 1259

Answers (1)

Mirte
Mirte

Reputation: 41

Remove the ) at the end of your query

Upvotes: 1

Related Questions