Exemplo n.º 1
0
        public DBOperate(string _connstr)
        {
            this.selfCreateConn = true;

            if (0 > _connstr.ToLower().IndexOf("provider="))
            {
                DBConnectByConfig ConnCfg = new DBConnectByConfig();
                if (!ConnCfg.InitConn(_connstr, "", ref this.conn))
                {
                    this.dbErr = ConnCfg.Error;
                }
            }
            else
            {
                if (null != this.conn)
                {
                    this.conn.Close();
                }

                if (IsOracle(_connstr))
                {
                    this.conn = new OleDbConnection();
                }
                else
                {
                    this.conn = new SqlConnection();
                }

                if (!DBConnectByConfig.ConnectDB(_connstr, ref this.conn))
                {
                    this.dbErr = "无法连接数据库";
                }
            }
        }
Exemplo n.º 2
0
        public DBOperate(string _configfile, string _db_config)
        {
            this.selfCreateConn = true;

            DBConnectByConfig ConnCfg = new DBConnectByConfig();

            if (!ConnCfg.InitConn(_configfile, _db_config, ref this.conn))
            {
                this.dbErr = ConnCfg.Error;
            }

            ConnCfg = null;
        }