Esempio n. 1
0
        public void SelectAeroports(ObservableCollection <Aeroport> l)
        {
            connection.Close();
            connection.Open();
            string          query  = "SELECT * FROM aeroport";
            MySqlCommand    cmd    = new MySqlCommand(query, connection);
            MySqlDataReader reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                Aeroport a = new Aeroport(reader.GetInt32(0), reader.GetString(1), reader.GetString(2), reader.GetString(3));
                l.Add(a);
            }
            reader.Close();
            connection.Close();
        }
Esempio n. 2
0
        public Aeroport ChooseAeroport(int id)
        {
            connection.Close();
            connection.Open();
            string       query = "SELECT * FROM aeroport where idAeroport = @id";
            MySqlCommand cmd   = new MySqlCommand(query, connection);

            cmd.Parameters.AddWithValue("@id", id);
            MySqlDataReader reader = cmd.ExecuteReader();
            Aeroport        b      = new Aeroport();

            if (reader.Read())
            {
                b = new Aeroport(reader.GetInt32(0), reader.GetString(1), reader.GetString(2), reader.GetString(3));
            }
            reader.Close();

            return(b);
        }