Re: Can PostgreSQL be used with ASP or .NET? - Mailing list pgsql-general

From rey4@columbia.edu (Russell Yanofsky)
Subject Re: Can PostgreSQL be used with ASP or .NET?
Date
Msg-id 7371185c.0202161501.6f6458da@posting.google.com
Whole thread Raw
In response to Re: Can PostgreSQL be used with ASP or .NET?  (aaasssxxx@hotmail.com (aaasssxxx))
List pgsql-general
> can you tell us how do you create the database object?

Here's an example of using postgres in C#. "site" is a system DSN that
is set up with a username and password.

using Microsoft.Data.Odbc;

...

OdbcConnection postgres;
postgres = new OdbcConnection("DSN=site");
postgres.Open();

OdbcCommand cmd = new OdbcCommand("SELECT language_id, name FROM
languages");
cmd.Connection = postgres;

OdbcDataReader reader = cmd.ExecuteReader();

while(reader.Read())
  Response.Write("<option value=" + reader.GetInt32(0) + ">"
    + reader.GetString(1) + "</option>\n");

reader.Close();
postgres.Close();
postgres = null;

To use ODBC in .NET you need the "ODBC .NET Data Provider" available
at

http://msdn.microsoft.com/downloads/sample.asp?url=/msdn-files/027/001/668/msdncompositedoc.xml

pgsql-general by date:

Previous
From: Doug McNaught
Date:
Subject: Re: User access to start and stop postmaster
Next
From: mhewii@qix.net (Mark & Candice White)
Date:
Subject: search array field?