ITPub博客

首页 > 数据库 > 国内数据库 > C#连接GBase 8s数据库在windows环境下使用步骤(二)

C#连接GBase 8s数据库在windows环境下使用步骤(二)

原创 国内数据库 作者:wj_2021 时间:2021-01-26 09:50:40 0 删除 编辑

上一篇已经介绍了如何搭建windows环境下C#连接GBase 8s数据库的环境,这篇就介绍一下,怎么使用吧

先来个简单的Demo

GbsConnectionStringBuilder build = new GbsConnectionStringBuilder();
build. Host = "192.168.1.1";
build. Service = "8080";
build. Server = "server";
build. Database= "dbname";
build. UID= "root";
build. Pwd= "a";

GbsConnection conn = new GbsConnection( build. ConnectionString);
conn. Open();

using( GbsCommand cmd = conn. CreateCommand())
{
cmd. CommandText = "select * from user"; GbsDataReader dr =
cmd. ExecureReader();
while( dr. Read())
{
Console. WriteLine( dr[ "id"]);
}
}


host:数据库ip

service:端口

server:实例名称

database:数据库名称

uid:用户名

pwd:密码


还可以设置字符集

ClientLocale

DbLocale

字符集一定要和数据库的设置成一致哒。


正常显示结果,木问题~



来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/69993860/viewspace-2752885/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2021-01-25

  • 博文量
    35
  • 访问量
    22868