Prudhvi Raj

Prudhvi Raj

  • NA
  • 17
  • 1.6k

Error near objCommand.ExecuteNonQuery();

May 3 2017 1:18 AM
 Error:
Exception thrown: 'System.Data.SqlClient.SqlException' in System.Data.dll
Additional information: Incorrect syntax near the keyword 'Table'.
 CODE:
string ConnectionString = "Data Source=LocalHost;Initial Catalog=radiant;Integrated Security=True;Pooling=False";
SqlConnection objconnection = new SqlConnection(ConnectionString);
objconnection.Open();
// fire the command object
string strInsertCommand = "Insert into table [Table ] Values('"
+ tbun.Text + "','"
+ cbcountry.Text + "','"
+ gender + "','"
+ hobbies + "',"
+ rbmarried.Checked + ")";
SqlCommand objCommand = new SqlCommand(strInsertCommand, objconnection);
objCommand.ExecuteNonQuery();
objconnection.Close();
 

Answers (5)