[Mono-list] test.cs Code Postgresql
Christian Mauricio Castillo Estrada
xpchristian@hotmail.com
Sat, 07 Feb 2004 04:59:12 +0000
Hi!
I've to modify the Mono.Data.PostgreSql.Client.dll (test.cs) example from
http://go-mono.com/postgresql.html , check this code:
/////////********************************************/////////////
Author: Christian Mauricio Castillo Estrada
using System;
using System.Data;
using Mono.Data.PostgreSqlClient;
public class Test
{
public static void Main(string[] args)
{
string connectionString =
"host=localhost;" +
"hostaddr=192.168.0.1;"+
"port=5432;"+
"dbname=pruebas;" +
"user=postgres;" +
"password=mypassword;";
IDbConnection dbcon;
dbcon = new PgSqlConnection(connectionString);
dbcon.Open();
IDbCommand dbcmd = dbcon.CreateCommand();
string sql = "SELECT * FROM tabla1";
dbcmd.CommandText = sql;
IDataReader reader = dbcmd.ExecuteReader();
while(reader.Read()) {
string FirstName = (string) reader["name"];
string LastName = (string) reader["lastname"];
Console.WriteLine("Student's Name: " + FirstName + " " +
LastName);
}
// clean up
reader.Close();
reader = null;
dbcmd.Dispose();
dbcmd = null;
dbcon.Close();
dbcon = null;
}
}
Miguel este el Codigo bueno... el codigo de la pagina de go-mono marca
errores cuando lo compilas actualizalo... no habian indicado el puerto, ni
la direccion ip y no estaba bien definido el PgSqlConnection.
ok bye
Atte,.
Christian M.Castillo Estrada
Happy Hacking
_________________________________________________________________
Únete al mayor servicio mundial de correo electrónico:
http://www.hotmail.com