C#操作PostgreSQL演示代码片段

c#
2015-05-02 0 467
C#操作PostgreSQL演示代码片段

先到网上下载PostgreSql.Data.PostgreSqlClient.dll

然后添加引用,使用命名空间

using PostgreSql.Data.PostgreSqlClient;
 
 
          string connectString = @"Server=localhost;Database=postgres;User ID=arwen;Password=arwen";
 
            PgConnection conn = new PgConnection(connectString);
 
            conn.Open();
 
            PgCommand cmd = conn.CreateCommand();
 
            cmd.CommandText = "select * from test";
 
            cmd.CommandType = CommandType.Text;
 
            using (PgDataReader reader = cmd.ExecuteReader())
 
            {
 
                while (reader.Read())
 
                    Console.WriteLine(reader[0].ToString());
 
            }

遇见资源网 c# C#操作PostgreSQL演示代码片段 http://www.ox520.com/12283.html

常见问题

相关文章

发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务