コード例 #1
0
ファイル: DataBase.cs プロジェクト: petitg/M2L-winform
        public static List <club> recupClub()
        {
            List <club>  Tableclub  = new List <club>();
            MySqlCommand maCommande = connection.CreateCommand();
            //
            MySqlDataReader maLigne;

            maCommande.CommandText = "select * from club";
            connection.Open();
            maLigne = maCommande.ExecuteReader();
            while (maLigne.Read())
            {
                string[] valeurColonnes = new string[7];
                for (int i = 0; i < maLigne.FieldCount; i++)
                {
                    valeurColonnes[i] = maLigne.GetValue(i).ToString();
                }
                string nom       = valeurColonnes[0];
                string site      = valeurColonnes[1];
                string adress    = valeurColonnes[2];
                string telephone = valeurColonnes[3];
                string mail      = valeurColonnes[4];
                string type      = valeurColonnes[5];
                int    id        = int.Parse(valeurColonnes[6]);

                club clu = new club(nom, site, adress, telephone, mail, type, id);
                Tableclub.Add(clu);
            }
            connection.Close();
            return(Tableclub);
        }
コード例 #2
0
ファイル: DataBase.cs プロジェクト: petitg/M2L-winform
        public static void ajoutClub(club unClub)
        {
            MySqlCommand maCommande = connection.CreateCommand();

            maCommande.CommandText = "insert into 'club' ('nom', 'site', 'adresse', telephone, email, type) values ( '" + unClub.getNom() + "', '" + unClub.getSite() + "','" + unClub.getAdresse() + "','" + unClub.getTelephone() + "','" + unClub.getEmail() + "','" + unClub.getType() + "')";
            connection.Open();
            maCommande.ExecuteReader();
            connection.Close();
        }