首页 > 代码库 > C#操作Advantage Database Server
C#操作Advantage Database Server
简单Demo:
引用 D:\Program Files (x86)\Advantage 11.10\ado.net\2.0\Advantage.Data.Provider.dll
using System;using Advantage.Data.Provider; namespace ADSDemo{ class Program { static void Main(string[] args) { // create a connection object // AdsConnection conn = new AdsConnection("data source=c:\\data;" + //"ServerType=remote|local; TableType=ADT"); //AdsConnection conn = new AdsConnection(); //conn.ConnectionString = "data source=c:\\data\\Demo2.add; " + //"user id = adssys; password = ‘‘ " + //"ServerType=local; TrimTrailingSpaces = true"; //AdsConnection conn = new AdsConnection(); //conn.ConnectionString = "data source=c:\\data\\Demo2.add; " + //"user id = adssys; " + //"ServerType=local; TrimTrailingSpaces = true"; AdsConnection conn = new AdsConnection(); conn.ConnectionString = "data source=c:\\data\\Demo2.add; " + "ServerType=local; TrimTrailingSpaces = true"; AdsCommand cmd; AdsDataReader reader; int iField; try { conn.Open(); // create a command object cmd = conn.CreateCommand(); // specify a simple SELECT statement cmd.CommandText = "select * from users"; // execute the statement and create a reader reader = cmd.ExecuteReader(); // dump the results of the query to the console while (reader.Read()) { for (iField = 0; iField < reader.FieldCount; iField++) Console.Write(reader.GetValue(iField) + " "); Console.WriteLine(); } conn.Close(); } catch (AdsException e) { Console.WriteLine(e.Message); } catch (System.Exception ex) { Console.WriteLine(ex.Message); } Console.ReadKey(); } }}
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。