C#连接SQL Anywhere 12 数据库

using System;
using System.Data.Common;

namespace ConsoleApplication27
{
    class Program
    {
        static void Main(string[] args)
        {
            DbProviderFactory dbFactory = DbProviderFactories.GetFactory("iAnywhere.Data.SQLAnywhere");
            DbConnection dbconn = dbFactory.CreateConnection();

            try
            {
                dbconn.ConnectionString = "User ID=dba;Password=sql;DataSourceName=\"SQL Anywhere 12 Demo\"";
                dbconn.Open();

                if (dbconn.State == System.Data.ConnectionState.Open)
                {
                    Console.WriteLine("Connection is Open!");

                    dbconn.Close();
                    if (dbconn.State == System.Data.ConnectionState.Closed)
                        Console.WriteLine("Connection is Closed!");
                }
            }
            catch (DbException dbexception)
            {
                Console.WriteLine(dbexception.Message);
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception.Message);
            }

            Console.ReadKey();
        }
    }
}

C#连接SQL Anywhere 12 数据库

上一篇:转载,Django组件


下一篇:干货:VLDB论文摘要-阿里技术突破性创新