Posts Npgsql provider
Post
Cancel

Npgsql provider

Is the .NET data provider for PostgreSQL. It allows any program developed for .NET framework to access a PostgreSQL database server. It is implemented in 100% C# code.

http://www.npgsql.org/doc/

https://github.com/npgsql/npgsql

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
using (var conn = new NpgsqlConnection("Host=myserver;Username=mylogin;Password=mypass;Database=mydatabase"))
{
    conn.Open();
    using (var cmd = new NpgsqlCommand())
    {
        cmd.Connection = conn;

        // Insert some data
        cmd.CommandText = "INSERT INTO data (some_field) VALUES ('Hello world')";
        cmd.ExecuteNonQuery();

        // Retrieve all rows
        cmd.CommandText = "SELECT some_field FROM data";
        using (var reader = cmd.ExecuteReader())
        {
            while (reader.Read())
            {
                Console.WriteLine(reader.GetString(0));
            }
        }
    }
}

origin - http://www.pipiscrew.com/?p=5707 net-npgsql-provider

This post is licensed under CC BY 4.0 by the author.
Contents

Trending Tags