I'm trying to update some data from a database and i have a problem in the code... It appears to be no errors but it doesn't update.
conexiune is my connector class cheltuieli is my table in the database and the rest of the names are the columns
the error is on this line: command.ExecuteNonQuery(); and the error appears when i click the button error: A first chance exception of type 'MySql.Data.MySqlClient.MySqlException' occurred in MySql.Data.dll
Additional information: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ''35', DistractieCultura '20', Neprevazute '30'' at line 1
I have no clue why... any thoughts?
private void button5_Click(object sender, EventArgs e)
{
try
{
if (textBox1.Text != "" & textBox2.Text != "" & textBox3.Text != "" & textBox4.Text != "" & textBox5.Text != "" & textBox6.Text != "")
{
MySqlConnection conexiune = null;
conexiune = Conector.getConnection();
MySqlCommand command = new MySqlCommand();
command.Connection = conexiune;
command.CommandText = "Update cheltuieli set Mancare = '" + textBox1.Text + "', Facturi = '" + textBox2.Text + "', Reparatii = '" + textBox3.Text + "', Altele '" + textBox4.Text + "', DistractieCultura '" + textBox5.Text + "', Neprevazute '" + textBox6.Text + "'";
command.ExecuteNonQuery();
MessageBox.Show("Actualizat!");
textBox1.Clear();
textBox2.Clear();
textBox3.Clear();
textBox4.Clear();
textBox5.Clear();
textBox6.Clear();
Search();
}
}
catch (Exception ex)
{
}
}
Aucun commentaire:
Enregistrer un commentaire