Have a good day, today I come with a problem that I have not been able to solve. I am working with C # .Net and a base in Microsoft Access, I am wanting to do an Update to a table.
The problem is that I do not know if I am correctly executing the use of parameters, besides I do not know if the query is actually running.
I have a MesssageBox to display that the data was updated, said MessageBox is displayed but it does not update the value in the table.
Here is the code for the "Save" button:
try
{
conexion.Open();
string update = "UPDATE usuarios set nombre = @nombre, tipo_usuario = @tipo_usuario, iniciales = @iniciales, identidad = @identidad, direccion = @direccion, telefono = @telefono, celular = @celular, correo = @correo WHERE codigo=@codigo";
OleDbCommand comando7 = new OleDbCommand(update, conexion);
comando7.Parameters.AddWithValue("@codigo", txtId.Text);
comando7.Parameters.AddWithValue("@nombre", txtNombre.Text);
comando7.Parameters.AddWithValue("@tipo_usuario", txtTipo.Text);
comando7.Parameters.AddWithValue("@iniciales", txtInciales.Text);
comando7.Parameters.AddWithValue("@identidad", txtIdentidad.Text);
comando7.Parameters.AddWithValue("@direccion", txtDireccion.Text);
comando7.Parameters.AddWithValue("@telefono", txtTelefono.Text);
comando7.Parameters.AddWithValue("@celular", txtCelular.Text);
comando7.Parameters.AddWithValue("@correo", txtCorreo.Text);
comando7.ExecuteNonQuery();
MessageBox.Show("Usuario actualizado con exito", "Exito", MessageBoxButtons.OK, MessageBoxIcon.Information);
this.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
finally
{
conexion.Close();
}
Then I would like to know if it is that way or if I have to change something to update the value since it is not updating. If they occupy any other info I will be pending. Thank you very much.