probleme quand delete rows d une table
bonjour j ai un probleme quand je veux supprimer des rows de ma table en utilisant dataset . ca genere une exception quand je veux supprimer 2 rows ou plus : "Concurrency violation: the DeleteCommand affected 0 of the expected 1 records "
mais ca kles supprime pareil sauf que ca donne une exception .
voici mon code
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
SqlConnection conn = new SqlConnection("data source=pc-s5;initial catalog=benamar;integrated security=true");
conn.Open();
SqlDataAdapter adpt = new SqlDataAdapter();
adpt.SelectCommand = new SqlCommand("select * from etudiant",conn);
DataSet ds = new DataSet();
adpt.Fill(ds,"etudiant2");
DataTable dt =ds.Tables["etudiant2"];
SqlCommand cmd=new SqlCommand("delete from etudiant where adress=@adress1",conn);
cmd.Parameters.Add(@"adress1",SqlDbType.VarChar,10,"adress");
string st = "adress=" +"'"+ textBox6.Text+"'";
foreach (DataRow ROW in dt.Select(st))
{
ROW.Delete();
}
adpt.DeleteCommand = cmd;
adpt.Update(ds,"etudiant2"); |
merci pour votre aide .