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 41
| private void xed(string requete_xed, string requete_xed_bis, string requete_Insertion_xed, string code_client, string mdp, string id_client, string bdd_idclient, string server_idclient, string utilisateur_idclient, string pwd_idclient, string id, string mp, string requete_verif)
{
//recupération du ID_CLIENT de la table CLIENT :
// Chaine de connexion
try
{
string connectString = "database='" + bdd_idclient + "'; server= '" + server_idclient + "';User ID='" + utilisateur_idclient + "'; pwd='" + pwd_idclient + "'";
// Objet connection
SqlConnection connection = new SqlConnection(connectString);
connection.Open();// Ouverture
//TRI IMPRIMANTE
// On selectionne le code_client le mot de passe de la table imprimante qui ne sont pas dans la table xed et qui ne sont pas nul avec id_du client
requete_xed = "SELECT DISTINCT(I.code_client), I.mdp_client, C.id_client FROM Imprimante I INNER JOIN Client C ON C.code_client = I.code_client WHERE I.code_client is not null AND I.mdp_client is not null AND NOT (I.code_client in(select login_xed from xed))AND NOT (I.mdp_client in(select mdp_xed from xed))";
// Création d'un objet SqlDataAdapter
SqlCommand Command = new SqlCommand(requete_xed, connection);
SqlDataReader dex = Command.ExecuteReader();
while (dex.Read())
{
code_client = dex["code_client"].ToString();
mdp = dex["mdp_client"].ToString();
id_client = dex["id_client"].ToString();
requete_Insertion_xed = "INSERT INTO xed VALUES('" + id_client.Replace("'", "''") + "','" + code_client.Replace("'", "''") + "','" + mdp.Replace("'", "''") + "') ";
Console.WriteLine(requete_Insertion_xed);
SqlCommand insert = new SqlCommand(requete_Insertion_xed, connection);
insert.ExecuteNonQuery();
insert.Dispose();
}
dex.Close();
connection.Close();
}
catch {
}
} |