C# simple code to write an INSERT query is giving an exception <p>I have a very basic and beginner problem. I got a 5 line code and I got exception in that.</p> <p>My database : <img src="https://i.imgur.com/Tgp35mL.png" alt="Table -&gt; id,name"></p> <p>It has one table and two columns inside the table viz. id and name. I made a form.</p> <p>Here is my code:</p> <pre><code>private void button1_Click(object sender, EventArgs e) { SqlConnection conn = new SqlConnection("Data Source=(LocalDB)\\v11.0;AttachDbFilename=\"C:\\Users\\Nicki\\documents\\visual studio 2012\\Projects\\WindowsFormsApplication2\\WindowsFormsApplication2\\Database2.mdf\";Integrated Security=True"); conn.Open(); SqlCommand command = new SqlCommand("INSERT INTO Table (id,name) VALUES (1,'" + textBox1.Text + "')", conn); command.ExecuteNonQuery(); conn.Close(); } </code></pre> <p>I get the following exception on running the code: <img src="https://i.imgur.com/cmpGuEV.png" alt=""></p> <p>It says that I have syntax error even though the syntax error is correct. Any help would be appreciated.</p> <p>Thankyou!</p>