通過odbc,c#連接pg數據庫
using System;
namespace Test
{
class mainClass
{
static void Main()
{
System.Data.Odbc.OdbcConnection conn=new System.Data.Odbc.OdbcConnection();
System.Data.Odbc.OdbcCommand cmd=new System.Data.Odbc.OdbcCommand();
conn.ConnectionString="Driver={PostgreSQL};Server=192.168.0.1;Database=test;Username=test;PassWord=test;";
try
{
conn.Open();
Console.WriteLine("{0}",conn.State);
}
catch (Exception ee)
{
Console.WriteLine(ee.Message);
}
}
}
}