通过odbc,c#连接pg数据库

类别:.NET开发 点击:0 评论:0 推荐:

通过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的下载地址:
http://laser.free-bsd.org/download/psqlodbc-07_03_0200.zip

本文地址:http://com.8s8s.com/it/it44514.htm