Saturday, July 02, 2005

c# datareader

:

using Console = System.Console;

using Microsoft.Data.Odbc;

class Postgres{
static void Main(){

OdbcConnection pgConnection = new OdbcConnection("DRIVER={PostgreSQL};UID=postgres-su;PWD=something;SERVER=127.0.0.1;Port=5432;Database=SH");
pgConnection.Open();

OdbcCommand pgCommand = new OdbcCommand();
pgCommand.CommandText = "SELECT * FROM item";
pgCommand.Connection = pgConnection;

OdbcDataReader pgReader;
pgReader = pgCommand.ExecuteReader();

while (pgReader.Read())
{
Console.WriteLine(pgReader["itemcode"] + pgReader["qty"]);
}

}

};

0 Comments:

Post a Comment

<< Home