public void chargeList(String from, String where, String what) { listInt.Clear(); String requete = "SELECT * FROM " + from; if (where != "") { requete = requete + " WHERE " + where; } try { //Ouverture connexion GestConn.Open(); //Requete SQL MySqlCommand MaCommande = new MySqlCommand(requete, GestConn); //Déclaration de Data Reader MySqlDataReader ReaderCalcul; //Exécution de la requête ReaderCalcul = MaCommande.ExecuteReader(); while (ReaderCalcul.Read()) { listInt.Add(double.Parse(ReaderCalcul[what].ToString())); } ReaderCalcul.Close(); GestConn.Close(); } catch (Exception ex) { MessageBox.Show("Erreur : " + ex.Message); } }
//Compte les éléments, sous certaines conditlions public int count(String from, String where) { int total = 0; String requete = "SELECT * FROM " + from; if (where != "") { requete = requete + " WHERE " + where; } try { //Ouverture connexion GestConn.Open(); //Requete SQL MySqlCommand MaCommande = new MySqlCommand(requete, GestConn); //Déclaration de Data Reader MySqlDataReader ReaderCalcul; //Exécution de la requête ReaderCalcul = MaCommande.ExecuteReader(); while (ReaderCalcul.Read()) { total++; } ReaderCalcul.Close(); GestConn.Close(); } catch (Exception ex) { MessageBox.Show("Erreur : " + ex.Message); } return(total); }