Пример #1
0
        public void ExecuteNonQuery(string sql)
        {
            var connectioStringProvider = new ConnectionStringProvider();
            var connection = new NpgsqlConnection(connectioStringProvider.GetConnectionString());

            connection.Open();
            var command = new NpgsqlCommand(sql, connection);

            command.ExecuteNonQuery();
            connection.Close();
        }
Пример #2
0
        public void Consultar(string identificador)
        {
            var           connectioStringProvider = new ConnectionStringProvider();
            var           connection = new NpgsqlConnection(connectioStringProvider.GetConnectionString());
            List <object> lista      = new List <object>();

            var command         = new NpgsqlCommand("SELECT nombre FROM hotel", connection);
            NpgsqlDataReader dr = command.ExecuteReader();

            if (dr.HasRows)
            {
                while (dr.Read())
                {
                    lista.Add(dr.GetString(0));
                    lista.Add(dr.GetString(1));
                    lista.Add(dr.GetString(2));
                    lista.Add(dr.GetString(3));
                    lista.Add(dr.GetString(4));
                    lista.Add(dr.GetString(5));
                }
            }
            connection.Close();
        }