示例#1
0
        public static SqlBase NewDB(string name)
        {
            SqlBase sb = String.IsNullOrEmpty(name) ? DefaultDB.NewOne() : DB[name].NewOne();

            sb.DSS = MyDss;
            return(sb);
        }
示例#2
0
        private static void InitDB()
        {
            if (_DB == null)
            {
                _DB = new Dictionary <String, SqlBase>();
            }
            if (_DB.Count > 0)
            {
                return;
            }
            foreach (ConnectionStringSettings css in MyDbSetting.GetAllConnections())
            {
                SqlBase sb = null;
                switch (MyDbSetting.GetProviderType(css.ProviderName))
                {
                case ProviderType.MsSql: sb = new MsSql(MyDbSetting, css.Name); break;

                case ProviderType.OleDb: sb = new OleDb(MyDbSetting, css.Name); break;

                case ProviderType.Odbc: sb = new Odbc(MyDbSetting, css.Name); break;

                case ProviderType.Oracle: sb = new Oracle(MyDbSetting, css.Name); break;

                case ProviderType.MySql: sb = new MySql(MyDbSetting, css.Name); break;
                }
                sb.DSS = MyDss;
                if (sb != null)
                {
                    if (!_DB.ContainsKey(css.Name))
                    {
                        _DB.Add(css.Name, sb);
                    }
                }
            }
        }
示例#3
0
 public DbResult(SqlBase sql)
 {
     this.IsConnected      = sql.IsConnected;
     this.ConnectionString = sql.ConnectionString;
     this.ExecError        = sql.ExecError;
     this.ConnError        = sql.ConnectError;
     this.CmdText          = sql.CmdText;
     this.ReturnValue      = sql.ReturnValue;
 }
示例#4
0
        public static System.Xml.XmlReader GetXmlReader(String cnName, string sSql)
        {
            SqlBase db = NewDB(cnName);

            db.Connect();
            if (!db.IsConnected)
            {
                return(null);
            }
            System.Xml.XmlReader xr = db.GetXmlReader(sSql);
            db.Close();
            return(xr);
        }
示例#5
0
        public static DbResult GetXDataTable_R(String cnName, string sSql)
        {
            SqlBase db = NewDB(cnName);

            db.Connect();
            if (!db.IsConnected)
            {
                return(new DbResult(db));
            }
            DbResult dr = db.GetXDataTable_R(sSql);

            db.Close();
            return(dr);
        }
示例#6
0
        public static XDataTable GetXDataTable(String cnName, string sSql)
        {
            SqlBase db = NewDB(cnName);

            db.Connect();
            if (!db.IsConnected)
            {
                return(null);
            }
            XDataTable xdt = db.GetXDataTable(sSql);

            db.Close();
            return(xdt);
        }
示例#7
0
        public static DataSet GetDataSet(String cnName, string sSql)
        {
            SqlBase db = NewDB(cnName);

            db.Connect();
            if (!db.IsConnected)
            {
                return(null);
            }
            DataSet ds = db.GetDataSet(sSql);

            db.Close();
            return(ds);
        }
示例#8
0
        public static DbValues GetDatas(String cnName, string sSql)
        {
            SqlBase db = NewDB(cnName);

            db.Connect();
            if (!db.IsConnected)
            {
                return(null);
            }
            DbValues dvs = db.GetDatas(sSql);

            db.Close();
            return(dvs);
        }
示例#9
0
        public static object GetDataReader(String cnName, string sSql)
        {
            SqlBase db = NewDB(cnName);

            db.Connect();
            if (!db.IsConnected)
            {
                return(-1);
            }
            object oR = db.GetDataReader(sSql);

            db.Close();
            return(oR);
        }
示例#10
0
        public static bool IsHasRow(String cnName, string sSql)
        {
            SqlBase db = NewDB(cnName);

            db.Connect();
            if (!db.IsConnected)
            {
                return(false);
            }
            bool blnR = db.IsHasRow(sSql);

            db.Close();
            return(blnR);
        }
示例#11
0
        public static object ExecuteGeneral(String cnName, CommandType cmdType, string sSql, object cmdParameters, CommandMode cmdMode)
        {
            SqlBase db = NewDB(cnName);

            db.Connect();
            if (!db.IsConnected)
            {
                return(null);
            }
            object oR = db.ExecuteGeneral(cmdType, sSql, cmdParameters, cmdMode);

            db.Close();
            return(oR);
        }
示例#12
0
        public static int Execute(String cnName, string sSql)
        {
            SqlBase db = NewDB(cnName);

            db.Connect();
            if (!db.IsConnected)
            {
                return(-1);
            }
            int iR = db.Execute(sSql);

            db.Close();
            return(iR);
        }
示例#13
0
        public static DbResult ExecuteGeneral_R(String cnName, CommandType cmdType, string sSql, object cmdParameters, CommandMode cmdMode)
        {
            SqlBase db = NewDB(cnName);

            db.Connect();
            object oR = null;

            if (db.IsConnected)
            {
                oR = db.ExecuteGeneral(cmdType, sSql, cmdParameters, cmdMode);
            }
            DbResult dr = new DbResult(db);

            db.Close();
            return(dr);
        }
示例#14
0
        public int DeleteFiles(String cnName, string sSql)
        {
            SqlBase db = NewDB(cnName);

            db.Connect();
            if (!db.IsConnected)
            {
                return(-1);
            }
            if (ULCode.QDA.Debug.IS_FORM_CLIENT)
            {
                return(-1);
            }
            int iR = db.DeleteFiles(sSql);

            db.Close();
            return(iR);
        }
示例#15
0
        public static SqlBase NewDB(ProviderType providerType, String connectionString)
        {
            SqlBase sb = null;

            switch (providerType)
            {
            case ProviderType.MsSql: sb = new MsSql(connectionString); break;

            case ProviderType.OleDb: sb = new OleDb(connectionString); break;

            case ProviderType.Odbc: sb = new Odbc(connectionString); break;

            case ProviderType.Oracle: sb = new Oracle(connectionString); break;

            case ProviderType.MySql: sb = new MySql(connectionString); break;
            }
            sb.DSS = MyDss;
            return(sb);
        }
示例#16
0
        public static DbResult Execute_R(String cnName, string sSql)
        {
            SqlBase db = NewDB(cnName);

            db.Connect();
            int iR = 0;

            if (!db.IsConnected)
            {
                iR = -1;
            }
            else
            {
                iR = db.Execute(sSql);
            }
            DbResult dr = new DbResult(db);

            dr.ReturnValue = iR;
            db.Close();
            return(dr);
        }