zoukankan      html  css  js  c++  java
  • 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();
            }
        }
    }

  • 相关阅读:
    十月八日学习报告
    十月七日学习报告
    十月六日学习报告
    十月五日学习报告
    十月三日学习报告
    为二级域名注册ssl证书,并强制使用https对http进行跳转
    google protobuf 数据类型_理解Protobuf数据格式解析
    JaveScript 中使用 XSLT转换XML文档
    移动端拖拽
    Web容器_Web服务器及常见的Web容器有哪些?
  • 原文地址:https://www.cnblogs.com/bisslot/p/3959566.html
Copyright © 2011-2022 走看看