通过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);
???}
??}
?}
}
ps:pg odbc的下载地址: