Ejemplo n.º 1
0
 /// <summary>
 /// 初始化
 /// </summary>
 private void Init()
 {
     OrderColumn    = "ID";
     OrderDirection = "ASC";
     SelectColumn   = " * ";
     PageIndex      = 0;
     PageSize       = 100000;
     DbType         = Config.DBType;
     if (Config.IsRWSeparate)
     {
         if (DbType.IsSQLite())
         {
             ConnString = Config.SQLiteReadConnectionString;
         }
         else if (DbType.IsSqlServer())
         {
             ConnString = Config.SqlServerReadDBConnectionString;
         }
         else if (DbType.IsOracle())
         {
             ConnString = Config.OracleReadDBConnectionString;
         }
         else if (DbType.IsMySQL())
         {
             ConnString = Config.MySqlConnectionString;
         }
     }
     else
     {
         if (DbType.IsSQLite())
         {
             ConnString = Config.SQLiteConnectionString;
         }
         else if (DbType.IsSqlServer())
         {
             ConnString = Config.SqlServerConnectionString;
         }
         else if (DbType.IsOracle())
         {
             ConnString = Config.OracleConnectionString;
         }
         else if (DbType.IsMySQL())
         {
             ConnString = Config.MySqlConnectionString;
         }
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// 设置数据库类型
 /// </summary>
 public SimpleQuery DBType(string _IDBType)
 {
     this.DbType = _IDBType;
     if (Config.IsRWSeparate)
     {
         if (DbType.IsSQLite())
         {
             ConnString = Config.SQLiteReadConnectionString;
         }
         else if (DbType.IsSqlServer())
         {
             ConnString = Config.SqlServerReadDBConnectionString;
         }
         else if (DbType.IsOracle())
         {
             ConnString = Config.OracleReadDBConnectionString;
         }
         else if (DbType.IsMySQL())
         {
             ConnString = Config.MySqlConnectionString;
         }
     }
     else
     {
         if (DbType.IsSQLite())
         {
             ConnString = Config.SQLiteConnectionString;
         }
         else if (DbType.IsSqlServer())
         {
             ConnString = Config.SqlServerConnectionString;
         }
         else if (DbType.IsOracle())
         {
             ConnString = Config.OracleConnectionString;
         }
         else if (DbType.IsMySQL())
         {
             ConnString = Config.MySqlConnectionString;
         }
     }
     return(this);
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 查询
        /// </summary>
        public DataTable Select()
        {
            DataTable reVal = new DataTable();

            if (DbType.IsSQLite())
            {
                try
                {
                    SQLiteHelper _DbHelp = new SQLiteHelper(ConnString);
                    reVal = _DbHelp.ExecuteDataTable(SQLiteSQL);
                }
                catch (Exception ex)
                {
                    ex.Data.Add("SimpleQuery-ConnString(SQLite)", ConnString);
                    ex.Data.Add("SimpleQuery-SQLiteSQL", SQLiteSQL);
                    throw ex;
                }
            }
            else if (DbType.IsSqlServer())
            {
                try
                {
                    SqlHelper _DbHelp = new SqlHelper(ConnString);
                    reVal = _DbHelp.ExecuteDataTable(SqlServerSQL);
                }
                catch (Exception ex)
                {
                    ex.Data.Add("SimpleQuery-ConnString(SqlServer)", ConnString);
                    ex.Data.Add("SimpleQuery-SqlServerSQL", SqlServerSQL);
                    throw ex;
                }
            }
            else if (DbType.IsMySQL())
            {
                try
                {
                    MySqlHelper _DbHelp = new MySqlHelper(ConnString);
                    reVal = _DbHelp.ExecuteDataTable(MySQL);
                }
                catch (Exception ex)
                {
                    ex.Data.Add("SimpleQuery-ConnString(MySQL)", ConnString);
                    ex.Data.Add("SimpleQuery-MySQL", MySQL);
                    throw ex;
                }
            }
            else if (DbType.IsOracle())
            {
                try
                {
                    OracleHelper _DbHelp = new OracleHelper(ConnString);
                    reVal = _DbHelp.ExecuteDataTable(SQLiteSQL);
                }
                catch (Exception ex)
                {
                    ex.Data.Add("SimpleQuery-ConnString(Oracle)", ConnString);
                    ex.Data.Add("SimpleQuery-OracleSQL", OracleSQL);
                    throw ex;
                }
            }
            return(reVal);
        }