コード例 #1
0
        public static Aeroport FindByName(string nom)
        {
            bdd.OpenConnection();
            string       query = "SELECT * FROM aeroport WHERE nom = @nom;";
            MySqlCommand cmd   = new MySqlCommand(query, bdd.GetConnection());

            cmd.Parameters.AddWithValue("@nom", nom);
            cmd.ExecuteNonQuery();
            MySqlDataReader reader = cmd.ExecuteReader();

            reader.Read();
            Aeroport aeroport = new Aeroport(reader.GetInt32(0), reader.GetString(1), reader.GetString(2), reader.GetInt32(3));

            reader.Close();
            bdd.CloseConnection();
            return(aeroport);
        }
コード例 #2
0
        public static List <string> SelectNomAeroports()
        {
            List <string> aeroports = new List <string>();

            bdd.OpenConnection();
            string       query = "SELECT * FROM aeroport;";
            MySqlCommand cmd   = new MySqlCommand(query, bdd.GetConnection());

            cmd.ExecuteNonQuery();
            MySqlDataReader reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                Aeroport aeroport = new Aeroport(reader.GetInt32(0), reader.GetString(1), reader.GetString(2), reader.GetInt32(3));
                aeroports.Add(aeroport.Nom);
            }
            reader.Close();
            bdd.CloseConnection();
            return(aeroports);
        }