public static ProDataSource ConnectDataSource(string HOST, string PORT, string SID, string UserId, string Password, bool sysdba)
        {
            //使用安装登录
            ProDataSource ds      = null;
            string        exMsg   = string.Empty;
            string        connstr = CreateConnetionString(HOST, PORT, SID, UserId, Password, sysdba);

            try
            {
                ds = new ProDynamicOracleDataSource(connstr);
                ds.Open();
            }
            catch (Exception ex) { ds = null; exMsg = ex.Message; }

            //免安装的连接方式
            string file = typeof(ProDynamicOracleDataSource).Assembly.CodeBase.Substring(8) + "\\Oracle.DataAccess.dll";

            if (ds == null && System.IO.File.Exists(file))
            {
                try
                {
                    Assembly      a    = Assembly.LoadFrom(file);
                    Type          type = a.GetType("Oracle.DataAccess.Client.OracleConnection");
                    IDbConnection conn = Activator.CreateInstance(type, true) as IDbConnection;
                    conn.ConnectionString = connstr;
                    ds = new ProDynamicOracleDataSource(conn);
                    ds.Open();
                }
                catch (Exception ex) { ds = null; exMsg = exMsg + "\n" + ex.Message; }
            }

            //微软的连接
            if (ds == null)
            {
                try
                {
                    ds = ProDataSourceFactory.CreateInstance(HOST, DatabasePlatformType.DB_Oracle, "", UserId, Password);
                    ds.Open();
                }
                catch (Exception ex) { ds = null; exMsg = exMsg + "\n" + ex.Message; }
            }

            if (ds == null)
            {
                throw new ApplicationException(exMsg);
            }
            return(ds);
        }
        /// <summary>
        /// 打开数据库连接
        /// </summary>
        /// <param name="dataSourceName">运行数据库对应的计算机名,一般为IP地址</param>
        /// <param name="catalog">数据库名称</param>
        /// <param name="username"></param>
        /// <param name="password"></param>
        /// <param name="dbType"></param>
        /// <returns></returns>
        public static ProDataSource CreateInstance(string dataSourceName, DatabasePlatformType dbType, string catalog = "", string username = "", string password = "")
        {
            string conString = "";

            switch (dbType)
            {
            case DatabasePlatformType.SQLServer:
                if (string.IsNullOrEmpty(dataSourceName) && string.IsNullOrEmpty(username))   //Windows身份验证模式,使用默认数据库实例;
                {
                    conString = string.Format("server=.;database={0};integrated security=SSPI", catalog);
                }
                else if (string.IsNullOrEmpty(username))   //如果不使用默认数据库实例,则用 server =./sid;
                {
                    conString = string.Format("server=./{0};database={1};integrated security=SSPI", dataSourceName, catalog);
                }
                else    //dataSourceName 一般为  ip/sid 模式
                {
                    conString = string.Format("Data Source={0};Initial Catalog={1};User ID={2};Password={3}", dataSourceName, catalog, username, password);
                }
                break;

            case DatabasePlatformType.DB_Oracle:
                conString = "Data Source=" + dataSourceName + ";User ID=" + username + ";Password="******"")  //dataSourceName为Access文件路径
                {
                    conString = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source=" + dataSourceName;
                }
                else
                {
                    conString = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source=" + dataSourceName + ";User ID=" + username;
                }
                if (password != null && password != string.Empty)
                {
                    conString = string.Format("{0};Persist Security Info=true;Jet OLEDB:Database Password={1}", conString, password);
                }
                break;

            default:
                conString = "Data Source=" + dataSourceName + ";Initial Catalog=" + catalog + ";User ID=" + username + ";Password=" + password;
                break;
            }
            connectionString = conString;
            databaseType     = dbType;
            return(ProDataSourceFactory.CreateInstance(conString, databaseType));
        }
        public static ProDataSource CreateInstance(DatabaseSite site)
        {
            string conString = "";

            switch (site.dataSourceType)
            {
            case DatabasePlatformType.SQLServer:
                if (string.IsNullOrEmpty(site.dataSourceName) && string.IsNullOrEmpty(site.userID))    //Windows身份验证模式,使用默认数据库实例;
                {
                    conString = string.Format("server=.;database={0};integrated security=SSPI", site.dbName);
                }
                else if (string.IsNullOrEmpty(site.userID))    //如果不使用默认数据库实例,则用 server =./sid;
                {
                    conString = string.Format("server=./{0};database={1};integrated security=SSPI", site.dataSourceName, site.dbName);
                }
                else    //dataSourceName 一般为  ip/sid 模式
                {
                    conString = string.Format("Data Source={0};Initial Catalog={1};User ID={2};Password={3}", site.dataSourceName, site.dbName, site.userID, site.passWord);
                }
                break;

            case DatabasePlatformType.DB_Oracle:
                conString = "Data Source=" + site.dataSourceName + ";User ID=" + site.userID + ";Password="******"Provider = Microsoft.Jet.OLEDB.4.0;Data Source=" + site.dataSourceName;
                break;

            default:
                conString = "Data Source=" + site.dataSourceName + ";Initial Catalog=" + site.dbName + ";User ID=" + site.userID + ";Password=" + site.passWord;
                break;
            }
            connectionString = conString;
            databaseType     = site.dataSourceType;
            return(ProDataSourceFactory.CreateInstance(conString, site.dataSourceType));
        }
 public static ProDataSource CreateInstance()
 {
     return(ProDataSourceFactory.CreateInstance(connectionString, databaseType));
 }