ITPub博客

首页 > 数据库 > > C#操作 Advantage Database Server 数据库

C#操作 Advantage Database Server 数据库

作者:飘絮絮絮丶 时间:2022-03-30 10:47:10 0 删除 编辑

相关下载

http://devzone.advantagedatabase.com/dz/content.aspx?key=31

1.安装数据库:       

Advantage Database Server

2.安装数据库工具:

Advantage Data Architect

3.安装.NET数据访问组件(Advantage.Data.Provider.dll for .net 2.0或Advantage.Data.Entity.dll for 3.5以上):

Advantage .NET Data Provider

 

简单Demo:

引用 D:\Program Files (x86)\Advantage 11.10\ado.net\2.0\Advantage.Data.Provider.dll

  1. using System;
  2. using Advantage.Data.Provider;
  3. namespace ADSDemo
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. // create a connection object
  10. // AdsConnection conn = new AdsConnection("data source=c:\\data;" +
  11. //"ServerType=remote|local; TableType=ADT");
  12. //AdsConnection conn = new AdsConnection();
  13. //conn.ConnectionString = "data source=c:\\data\\Demo2.add; " +
  14. //"user id = adssys; password = '' " +
  15. //"ServerType=local; TrimTrailingSpaces = true";
  16. //AdsConnection conn = new AdsConnection();
  17. //conn.ConnectionString = "data source=c:\\data\\Demo2.add; " +
  18. //"user id = adssys; " +
  19. //"ServerType=local; TrimTrailingSpaces = true"; //AdsConnection conn = new AdsConnection("Data Source=\\\\127.0.0.1:6262\\data\\Demo2.add;ServerType=REMOTE;User ID=AdsSys;Password=XXXXX;");
  20. AdsConnection conn = new AdsConnection();
  21. conn.ConnectionString = "data source=c:\\data\\Demo2.add; " +
  22. "ServerType=local; TrimTrailingSpaces = true";
  23. AdsCommand cmd;
  24. AdsDataReader reader;
  25. int iField;
  26. try
  27. {
  28. conn.Open();
  29. // create a command object
  30. cmd = conn.CreateCommand();
  31. // specify a simple SELECT statement
  32. cmd.CommandText = "select * from users";
  33. // execute the statement and create a reader
  34. reader = cmd.ExecuteReader();
  35. // dump the results of the query to the console
  36. while (reader.Read())
  37. {
  38. for (iField = ; iField < reader.FieldCount; iField++)
  39. Console.Write(reader.GetValue(iField) + " ");
  40. Console.WriteLine();
  41. }
  42. conn.Close();
  43. }
  44. catch (AdsException e)
  45. {
  46. Console.WriteLine(e.Message);
  47. }
  48. catch (System.Exception ex)
  49. {
  50. Console.WriteLine(ex.Message);
  51. }
  52. Console.ReadKey();
  53. }
  54. }
  55. }

转载于:https://www.cnblogs.com/lonelyxmas/p/3790031.html

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

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

注册时间:2019-09-09

  • 博文量
    2646
  • 访问量
    42257