I'm using the code below in the attempt to take text from a textbox to add it to a SQL table called 'Name'. The commented code is the code provided by default as the button's code which I attempted to replace below. The program runs fine however the SQL table isn't updated upon pressing the button nad I was hoping you could provide an insight as to why.
private void nameBindingNavigatorSaveItem_Click(object sender, EventArgs e)
{
//this.Validate();
//this.nameBindingSource.EndEdit();
//this.tableAdapterManager.UpdateAll(this.cLIENTDB3DataSet);
string cmdString = "INSERT INTO Name VALUES (@val1)";
using (connection = new SqlConnection(connectionString))
{
using (SqlCommand comm = new SqlCommand(cmdString,connection))
{
connection.Open();
comm.Connection = connection;
comm.CommandText = cmdString;
comm.Parameters.AddWithValue("@val1", nameTextBox.Text);
comm.ExecuteNonQuery();
}
}
}
Thanks!