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?
Fill
method requests data from the database in the DataTable. That is, it needs aSELECT
sql command. And you haveUPDATE
. Accordingly, use theUpdate
method of the adapter. - Alexander Petrov