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"); |
Partager