Je sais que cette question a déjà été posée mais je ne comprends toujours pas pourquoi mon code n'est pas mis à jour dans la base de données. Ce code n'a pas d'erreur mais il ne change pas les données dans la base de données. Quelqu'un s'il vous plaît aidez-moi. Voici mon code:Comment mettre à jour dans la base de données
private void button1_Click_1(object sender, EventArgs e)
{
con.Open();
bool exists2;
using (SqlCommand cmd2 = new SqlCommand("select count(*) from [m_emp_photo] where [email protected]", con))
{
cmd2.Parameters.AddWithValue("@empno", textBoxEmpNo.Text);
cmd2.Parameters.AddWithValue("@path", textBoxImgPath.Text);
exists2 = (int)cmd2.ExecuteScalar() > 0;
}
if (exists2)
{
string query2 = "";
//query2 = "update m_emp_photo set [email protected] where [email protected]";
query2 = "UPDATE m_emp_photo set [email protected] where [email protected]";
SqlCommand cmd2;
cmd2 = new SqlCommand(query2, con);
cmd2.Parameters.AddWithValue("@path", textBoxImgPath.Text);
MessageBox.Show("Changes has been saved!");
}
else
{
MessageBox.Show("No record found");
}
con.Close();
}
Merci pour votre aide! ça marche :) – Miza