I want to make a request to update the data. Here is my code.

string query2 = "UPDATE Auth SET(login = '" + txtLogin.Text+ "', password = '" + txtNewPassword.Text + "', name = '" + txtName.Text + "' WHERE login = '" + txtLogin.Text +"')"; MySqlConnection MyCon2 = new MySqlConnection(connectionString); MySqlCommand command2 = new MySqlCommand(query2, MyCon2); MySqlDataAdapter adapter2 = new MySqlDataAdapter(command2); DataTable table2 = new DataTable(); adapter2.Fill(table2); MessageBox.Show("Данные обновлены"); this.Close(); 

What is the problem?

  • And what about some kind of error? - PECHAIR
  • Add error checking or catch an exception and output information about errors returned by the DB. And there are a lot of problems, for example, substituting variable values ​​directly into the query text, if they contain quotation marks, then everything will break. In addition, it is completely unclear why after the set the parenthesis opens and why it closes only after where. - Mike
  • The Fill method requests data from the database in the DataTable. That is, it needs a SELECT sql command. And you have UPDATE . Accordingly, use the Update method of the adapter. - Alexander Petrov
  • And for heaven's sake, read about parameterized sql queries! - Alexander Petrov

0