由上篇文章进行使用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驱动来连接数据库,并操作数据库。