Re: PostgreSQL and C#

From: Matthew Stanfield <matthew(at)propertyknowledge(dot)com>
To: Daniel Morgan <danmorg(at)sc(dot)rr(dot)com>
Cc: PostgreSQL General Mailing List <pgsql-general(at)postgresql(dot)org>
Subject: Re: PostgreSQL and C#
Date: 2002-04-09 17:38:33
Message-ID: 3CB32719.E89C22DD@propertyknowledge.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgadmin-hackers pgsql-general

This email just got returned to me as a failed delivery so I am resending
it, apologies if anyone gets it twice. Matthew

> I really want to use C# and .NET to query PostgreSQL 7.2 databases?

Hi Daniel,

The way I have done it is by using ODBC. You will need to download:
odbc.net from the microsoft site (URL below) and the postgresql odbc driver
(URL below).

Some of the .net CLR database orientated classes are specific to
Microsoft's SQL Server so you can't use them. odbc.net provides a suite of
classes such as OdbcConnection, OdbcCommand and OdbcDataReader; which, so
far, have been really easy to use (see mini example below).

> Do I need to get the source the PostgreSQL database itself?

Absolutely not! I highly recommend you using odbc.net to connect to
postgresql, it is simple to use (and learn), fast and has, so far, been bug
free.

postgresql odbc site:
http://odbc.postgresql.org

odbc.net is here:
http://msdn.microsoft.com/downloads/default.asp?URL=/downloads/sample.asp?url=/MSDN-FILES/027/001/668/msdncompositedoc.xml

Mini Example:

string query = "SELECT * FROM testtable";
OdbcConnection odbcCon = new OdbcConnection("DSN=PostgreSQL");
OdbcCommand odbcCom = new OdbcCommand(query, odbcCon);
odbcCon.Open();
OdbcDataReader odbcReader =
odbcCom.ExecuteReader(CommandBehavior.CloseConnection);
Then you can start 'reading'.

Good luck,

..matthew

In response to

Responses

Browse pgadmin-hackers by date

  From Date Subject
Next Message Daniel Morgan 2002-04-10 13:04:55 Re: PostgreSQL and C#
Previous Message Matthew Stanfield 2002-04-09 15:47:16 Re: PostgreSQL and C#

Browse pgsql-general by date

  From Date Subject
Next Message Ed Loehr 2002-04-09 17:44:08 Re: Hash Join vs Nested Loops in 7.2.1 ...
Previous Message Fran Fabrizio 2002-04-09 17:34:41 Re: Getting statistics from tables