title: Inserting values into a SQL Server database using ado.net via C#
body: <p>I have created a simple program to insert values into the table <code>[regist]</code>, but I keep getting the error </p>
  
  <blockquote>
    <p><em>Incorrect syntax near ')'</em></p>
  </blockquote>
  
  <p>on <code>cmd.ExecuteNonQuery();</code>:</p>
  
  <pre><code> private void button1_Click(object sender, EventArgs e)
   {
        SqlConnection cn = new SqlConnection("Data Source=DELL-PC;initial catalog=AdventureWorks2008R2 ; User ID=sa;Password=sqlpass;Integrated Security=SSPI;");
  
        SqlCommand cmd = new SqlCommand("INSERT INTO dbo.regist (" + " FirstName, Lastname, Username, Password, Age, Gender,Contact, " + ") VALUES (" + " @textBox1.Text, @textBox2.Text, @textBox3.Text, @textBox4.Text, @comboBox1.Text,@comboBox2.Text,@textBox7.Text" + ")", cn);
  
        cn.Open();
        cmd.ExecuteNonQuery();
        cn.Close();
  }
  </code></pre>
  
  <p>I am new to this and I am really confused. </p>