/// <summary> /// 构造函数 /// </summary> /// <param name="dbType">数据库类型(MYSQL/ORACLE/SQLSERVER/POSTGRESQL/DB2/SYBASE/INFORMIX)</param> /// <param name="connStr">连接字符串</param> public BDBHelper(string dbType, string connStr) { _dbType = dbType; _connStr = connStr; _db = GetDBOperator(dbType, connStr); _db.Open(); }
/// <summary> /// 构造函数 /// </summary> /// <param name="dbType">数据库类型(MYSQL/ORACLE/SQLSERVER/POSTGRESQL/DB2/SYBASE/INFORMIX)</param> /// <param name="ip">数据库主机IP</param> /// <param name="port">主机端口</param> /// <param name="userName">登录账号</param> /// <param name="password">登录密码</param> /// <param name="database">数据库名</param> /// <param name="serviceName">服务名/实例名(可选,Oracle必填,为服务名)</param> public BDBHelper(string dbType, string ip, int port, string userName, string password, string database, string serviceName = "") { _dbType = dbType; _db = GetDBOperator(dbType, ip, port, userName, password, database, serviceName); _connStr = _db.ConnString; _db.Open(); }
/// <summary> /// 构造函数,数据库类型及连接字符串会读取默认配置项DataBaseType、ConnString /// </summary> public BDBHelper() { _dbType = Config.BConfig.GetConfigToString(ConfigKeyForDataBaseType); _connStr = Config.BConfig.GetConfigToString(ConfigKeyForConnString); _db = GetDBOperator(_dbType, _connStr); _db.Open(); }