I can not update a table from a database linked to a datagrid. When I change the data in the cells of the datagrid, although they appear changed during the debug, at the end the table is not updated. Does anyone know what's missing in the code?
private static OdbcConnection CreateConnection()
{
return new OdbcConnection("driver= {MySQL ODBC 5.1 Driver};server=192.168.20.29; database=yyyy; uid=esta; password=1234; option = 3 ");
}
using (OdbcConnection connection = CreateConnection())
{
string CmdText = "update lojas set Bloqueado =@bloqueador, DataFim = @DataFim, Nome = @Nome where Id =@Id";
OdbcCommand cm = new OdbcCommand(CmdText, connection);
cm.CommandType = CommandType.Text;
connection.Open();
cm.Parameters.AddWithValue("@Id", grid_lic.CurrentRow.Cells[0].Value);
cm.Parameters.AddWithValue("@bloqueador",grid_lic.CurrentRow.Cells[3].Value);
cm.Parameters.AddWithValue("@DataFim",grid_lic.CurrentRow.Cells[4].Value);
cm.Parameters.AddWithValue("@Nome",grid_lic.CurrentRow.Cells[6].Value);
cm.ExecuteNonQuery();
}