首页 > 数据库技术 > 详细

C#操作Advantage Database Server

时间:2014-06-16 23:42:47      阅读:651      评论:0      收藏:0      [点我收藏+]

简单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();
        }
    }
}

  

C#操作Advantage Database Server,布布扣,bubuko.com

C#操作Advantage Database Server

原文:http://www.cnblogs.com/lonelyxmas/p/3790031.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!