As I posted in another forum:
A few questions and then a sample:
1. What version of PSQL are you using?
2. Do you have DDFs for your data?
The sample below uses ODBC to connect to a PSQL database. There may be other options depending on the version you are using.
Now the sample:
Code:
using System;
using System.Data;
using System.Data.Odbc;
using System.IO;
namespace SimpleADONetTest
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
try
{
OdbcConnection conn=new OdbcConnection("DSN=DEMODATA");
conn.Open();
Console.WriteLine("ServerName: " + conn.ServerName.ToString());
Console.WriteLine("ServerDSN: " + conn.ServerDSN.ToString());
// Create a SQL command
string strSQL = "select * from class";
OdbcCommand DBCmd = new OdbcCommand(strSQL, conn);
OdbcDataReader myDataReader;
myDataReader = DBCmd.ExecuteReader();
Console.WriteLine("FieldCount: " + myDataReader.FieldCount.ToString());
while (myDataReader.Read())
{
for (int i=0;i
{
Console.WriteLine("Field " + i.ToString() + ": " + myDataReader[i].ToString());
}
}
myDataReader.Close();
conn.Close();
Console.WriteLine("Press Enter to continue");
Console.ReadLine();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
Console.ReadLine();
}
}
}
}