1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
| OleDbConnection cnx = new OleDbConnection();
cnx.ConnectionString = ads_filiere.ConnectionString;
OleDbCommand cmd = new OleDbCommand();
OleDbCommand cmd2 = new OleDbCommand();
OleDbCommand cmd3 = new OleDbCommand();
cmd.Connection = cnx;
cmd2.Connection = cnx;
cmd3.Connection = cnx;
cnx.Open();
cmd.CommandText = "select nom, ville from [activ-client], clients where activité='" + txtselectedvalue2.Text + "'";
cmd2.CommandText = "select marque from marqueclient where activité='" + txtselectedvalue2.Text + "'";
OleDbDataReader dr2 = cmd2.ExecuteReader();
OleDbDataReader dr = cmd.ExecuteReader();
string str= "impossible de supprimer l'activité sélectionnée : elle est référencée pour ";
int niv = activ.SelectedNode.Depth;
string req ="";
switch (niv) {
case 0:
txtromsg.Text = "impossible de supprimer le noeud racine";
break;
case 1:
req = "delete * from filiereproduit where filiere='" + txtselectedvalue2.Text + "'";
break;
case 2:
req = "delete * from brancheproduit where branche='" + txtselectedvalue2.Text + "'";
break;
case 3:
req = "delete * from spécialitéproduit where spécialité='" + txtselectedvalue2.Text + "'";
break;}
if (dr.HasRows)
while (dr.Read())
str = str + dr.GetString(0) + " , " + dr.GetString(1);
if (dr2.HasRows)
while (dr2.Read())
str = str + dr2.GetString(0);
cmd3.CommandText = req;
Response.Write (req);
cmd3.ExecuteNonQuery();
activ_Load();
cnx.Close(); |