I have an edit form for values in datagridview. The problem is with update code. The whole code updated:
int value = int.Parse(label13.Text); // ID
string txtbox2 = textBox2.Text.ToString();
string txtbox1 = textBox1.Text.ToString();
try
{
var cmd = new OleDbCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "UPDATE guestreg SET g_name='" + txtbox1 + "' AND g_surname = '"+txtbox2+"' where ID =@id";
cmd.Parameters.AddWithValue("@id", value);
cmd.Connection = connection;
connection.Open();
cmd.ExecuteNonQuery();
{
MessageBox.Show("Update Success!");
connection.Close();
}
When the update sql command contains just one value to update - it works (example) :
cmd.CommandText = "UPDATE guestreg SET g_name='" + textBox1.Text + "' where ID =@id";
The values not updating at all. But message box shows that everything was done.
Just changes name to "0".
Thanks a lot.