Re: Can PostgreSQL be used with ASP or .NET?
| От | rey4@columbia.edu (Russell Yanofsky) |
|---|---|
| Тема | Re: Can PostgreSQL be used with ASP or .NET? |
| Дата | |
| Msg-id | 7371185c.0202161501.6f6458da@posting.google.com обсуждение исходный текст |
| Ответ на | Re: Can PostgreSQL be used with ASP or .NET? (aaasssxxx@hotmail.com (aaasssxxx)) |
| Список | 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 по дате отправления: