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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
   |  
private void (string requete1, string requete1_bis, string requete_Insertion_, string code_athlete, string mdp, string id_athlete, string bdd_idathlete, string server_idathlete, string utilisateur_idathlete, string pwd_idathlete, string id, string mp, string requete_verif)
        {
            //recupération du ID_athlete de la table athlete :
            // Chaine de connexion
            try
            {
 
                string connectString = "database='" + bdd_idathlete + "'; server='" + server_idathlete + "';User ID='" + utilisateur_idathlete + "'; pwd='" +pwd_idathlete + "'";
                // Objet connection
                SqlConnection connection = new SqlConnection(connectString);
 
                connection.Open();// Ouverture
                //TRI IMPRIMANTE
 
 
                requete1 = "SELECT * FROM imprimante WHERE code_athlete is not null AND mdp_athlete is not null";
        // Création d'un objet SqlDataAdapter
                SqlCommand Command = new SqlCommand(requete1, connection);
                SqlDataReader dex = Command.ExecuteReader();
 
                while (dex.Read())
                {
                    code_athlete = dex["code_athlete"].ToString();
                    mdp = dex["mdp_athlete"].ToString();
 
                    requete_verif = "SELECT * FROM  ";
                    SqlCommand verif_ = new SqlCommand(requete_verif, connection);
                    SqlDataReader verif_dex = verif_.ExecuteReader();
 
                    while (verif_dex.Read())
                    {
                        id = verif_dex["LOGIN_"].ToString();
                        mp = verif_dex["MDP_"].ToString();
                        Console.WriteLine(id + "--" + mp);
                        if ((id != code_athlete) && (mp != mdp))
                        {
 
                            requete1_bis = "SELECT id_athlete FROM athlete WHERE code_athlete ='" + code_athlete + "'";
                            SqlCommand insert_ = new SqlCommand(requete1_bis, connection);
                            //// Objet DataReader
                            Console.WriteLine(requete1_bis);
                            SqlDataReader dex_bis = insert_.ExecuteReader();
                            while (dex_bis.Read())
                            {
                                Console.WriteLine(requete1_bis);
 
                                id_athlete = dex_bis["id_athlete"].ToString();
 
                                requete_Insertion_ = "INSERT INTO  VALUES('" + id_athlete.Replace("'", "''") + "','" + code_athlete.Replace("'", "''") + "','" + mdp.Replace("'", "''") + "') ";
                                Console.WriteLine(requete_Insertion_);
                                SqlCommand insert = new SqlCommand(requete_Insertion_, connection);
                                insert.ExecuteNonQuery();
                                insert.Dispose();
                            }
                            dex_bis.Close();
                        }
                    } verif_dex.Close();
                 }
                dex.Close();
 
                connection.Close();
            } | 
Partager