Fernando Calabro

Fernando Calabro

  • NA
  • 33
  • 2.1k

Error updating MySql record in C # from Visual Studio

Sep 5 2020 10:33 PM
Good night. Sorry to bother you. I am having a problem that is driving me crazy and I cannot find the fault. Design a program that, among other functions, has one that allows you to generate a receipt for the database and send it automatically by email. The configuration of the email account (address, user, password, host, port, ssl) I have saved in a database table, and every time I give the order to carry out that backup operation, it raises the configuration of the email account from that table. That works perfect. The issue is that I create a form, which upon entering, automatically raises all those settings and displays them in different textboxes. I did this in case at some point I decide to change any of that data (for example, the email or password, from there I can do it), but when I want to update that information with a button so that it is saved in said update in the database data, it throws me an error and automatically sends me to the "Program.cs" configuration and marks the Login form. It should be noted that the code used for this update is the same as that used in another form where it works perfectly (obviously that it changes the names of the fields). I attach the code. THANK YOU.- private void btnactualizar_Click(object sender, EventArgs e) { conexion_email.Open(); string actualizarconfiguracion = "update clientes set idconfiguraciones_email ='" + txtid.Text + "',DIRECCION_EMAIL ='" + txtdireccion.Text + "',USUARIO ='" + txtusuario.Text + "',PASSWORD ='" + txtpassword.Text + "',HOST ='" + txthost.Text + "',PUERTO ='" + txtpuerto.Text + "',SSL ='" + txtssl.Text + "',DIRECCION_RESGUARDO ='" + txtdireccionresguardo.Text + "' where idconfiguraciones_email =" + txtid.Text; MySqlCommand comando_configuracion = new MySqlCommand(actualizarconfiguracion, conexion_email); comando_configuracion.ExecuteNonQuery(); conexion_email.Close(); MessageBox.Show("Configuracion Actualizada Correctamente"); }

Answers (3)