* PostgreSQL Data Provider ** Current Status ** Action Plan

More testing and fixing bugs...

Eventually replace the PostgreSQL data provider in Mono with Npgsql. Npgsql is a .Net Data Provider for PostgreSQL which implements the PostgreSQL Frontend/Backend Protocol. Npgsql is implemented in 100% C#. This provider was created by Francisco Figueiredo jr. and has many programmers developing the provider. ** Testing Mono's Mono.Data.PostgreSqlClient

Installation instructions for PostgreSQL DBMS: On Unix

On Windows

In the path mcs/class/System.Data/Test there is a test for Mono.Data.PostgreSqlClient named PostgreTest.cs. Thanks goes to Gonzalo for creating the original PostgreSQL test.

To compile the PostgresTest.cs program, do:

 mcs PostgresTest.cs \
    -r System.Data.dll \
    -r Mono.Data.PostgreSqlClient.dll

If there are compile errors, such as, can not convert IDbConnection to PgSqlConnection, then you need to run mcs like:

 mono C:/cygwin/home/MyHome/mono/install/bin/mcs.exe \
    PostgresTest.cs \
    -r System.Data.dll \
    -r Mono.Data.PostgreSqlClient.dll

To run using mint, do:

mint PostgresTest.exe

To run using mono, do:

mono PostgresTest.exe

C# Example for Mono.Data.PostgreSqlClient:

 using System;
 using System.Data;
 using Mono.Data.PostgreSqlClient;
 
 public class Test 
 {
    public static void Main(string[] args)
    {
       string connectionString = 
          "Server=localhost;" +
          "Database=test;" +
          "User ID=postgres;" +
          "Password=fun2db;";
       IDbConnection dbcon;
       dbcon = new PgConnection(connectionString);
       IDbCommand dbcmd = dbcon.CreateCommand();
       // requires a table to be created named employee
       // with columns firstname and lastname
       // such as,
       //        CREATE TABLE employee (
       //           firstname varchar(32),
       //           lastname varchar(32));
       string sql = 
           "SELECT firstname, lastname" + 
           "FROM employee";
       dbcmd.ConnectionString = sql;
       IDataReader reader = dbcmd.ExecuteReader();
       while(reader.Read()) {
            string FirstName = reader["firstname"];
            string LastName = reader["lastname"];
            Console.WriteLine("Name: " + 
                FirstName + " " + LastName);
       }
       // clean up
       reader.Close();
       reader = null;
       dbcmd.Dispose();
       dbcmd = null;
       dbcon.Close();
       dbcon = null;
    }
 }
  • Building C# Example:
  • Running the Example:
    mono TestExample.exe
    
  • ** Testing Npgsql