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

  • 相关阅读:
    DataType--数值类型
    Scala中List(Map1,Map2,Map3 ....) 转成一个Map
    Scala中集合类型与java中集合类型转换
    oracle查询数据库最大连接数等信息
    kafka_2.11-0.10.2.1中的auto.offset.reset
    IOS设备信息与机型对照表
    shell 后台执行脚本
    Spark的操作列表
    hive表支持中文设置
    编译Spark2.1.2源码
  • 原文地址:https://www.cnblogs.com/bisslot/p/3959566.html
Copyright © 2011-2022 走看看