Linux下通过mono_C# + FreeTDS连接sqlserver数据库

来源:互联网 发布:java怎么实现序列化 编辑:程序博客网 时间:2024/04/30 16:53

由上篇文章进行使用FreeTDS建立ODBC连接sqlserver;
此篇文章将通过mono_C#来操作数据库;

测试代码如下:
static void Main(string[] args)
{
try
{
String sql = “SELECT callid FROM tables”;
string connStr = “Driver=FREETDS;Server=.;Database=callcenter;Port=1433;TDS_Version=8.0;UID=sa;PWD=*;client charset = UTF8;”;
Console.WriteLine(connStr);
OdbcDataAdapter da = new OdbcDataAdapter(sql, connStr);
// Create the table, fill it, and bind the default view to the grid.
DataTable dt = new DataTable();
da.Fill(dt);
Console.ReadLine();
}
catch (Exception ex)
{
Console.WriteLine(“error:” + ex.ToString());
Console.ReadLine();

  }

通过 FREETDS驱动来连接数据库,并操作数据库。

0 0
原创粉丝点击