public DbDataAdapterCommon(Opt_DataBaseType dataBaseType, DbCommand dbCommand)
 {
     //get dbAdapter
     this.DbDataAdapter = GetDbAdapter(dataBaseType, dbCommand);
     //provid select command
     this.SelectCommand = dbCommand;
 }
 /**
  * if read db disabled,switchover to read write db immediately
  * */
 public SqlConnection_WR_Safe(Opt_DataBaseType dataBaseType, string ConnString_R, string ConnString_RW)
 {
     try
     {
         this.DbConnection = GetDbConnection(dataBaseType, ConnString_R);
     }
     catch (Exception)
     {
         this.DbConnection = GetDbConnection(dataBaseType, ConnString_RW);
     }
 }
Beispiel #3
0
        /// <summary>
        /// SqlTypeToLanguageType
        /// </summary>
        /// <param name="dataBaseType"></param>
        /// <param name="language"></param>
        /// <param name="typeString"></param>
        /// <returns></returns>
        public static string SqlTypeToLanguageType(Opt_DataBaseType dataBaseType, Opt_Language language, string typeString)
        {
            switch (dataBaseType)
            {
            case Opt_DataBaseType.SqlServer:
                switch (language)
                {
                case Opt_Language.Java: return(SQLServerTypeConvert.SqlTypeStringToJavaTypeString(typeString));

                case Opt_Language.Net: return(SQLServerTypeConvert.SqlTypeStringToNetTypeString(typeString));

                case Opt_Language.Python: return(string.Empty);

                case Opt_Language.JavaScript: return(string.Empty);

                case Opt_Language.Ruby: return(string.Empty);

                case Opt_Language.Go: return(string.Empty);

                case Opt_Language.VB: return(string.Empty);

                default: return(string.Empty);
                }

            case Opt_DataBaseType.MySql:
                switch (language)
                {
                case Opt_Language.Java: return(MySqlTypeConvert.SqlTypeStringToJavaTypeString(typeString));

                case Opt_Language.Net: return(MySqlTypeConvert.SqlTypeStringToNetTypeString(typeString));

                case Opt_Language.Python: return(string.Empty);

                case Opt_Language.JavaScript: return(string.Empty);

                case Opt_Language.Ruby: return(string.Empty);

                case Opt_Language.Go: return(string.Empty);

                case Opt_Language.VB: return(string.Empty);

                default: return(string.Empty);
                }

            case Opt_DataBaseType.Oracle: return(string.Empty);

            default: return(string.Empty);
            }
        }
        private DbDataAdapter GetDbAdapter(Opt_DataBaseType dataBaseType, DbCommand dbCommand)
        {
            switch (dataBaseType)
            {
            case Opt_DataBaseType.SqlServer:
                return(new SqlDataAdapter());

            case Opt_DataBaseType.MySql:
                return(new MySqlDataAdapter());

            case Opt_DataBaseType.Oracle:
                return(new OracleDataAdapter());

            default:
                return(new SqlDataAdapter());
            }
        }
        /// <summary>
        /// Get DbCommand select database type
        /// </summary>
        /// <param name="dataBaseType"></param>
        /// <returns></returns>
        private DbCommand GetDbCommand(Opt_DataBaseType dataBaseType)
        {
            switch (dataBaseType)
            {
            case Opt_DataBaseType.SqlServer:
                return(new SqlCommand());

            case Opt_DataBaseType.MySql:
                return(new MySqlCommand());

            case Opt_DataBaseType.Oracle:
                return(new OracleCommand());

            default:
                return(new SqlCommand());
            }
        }
        /// <summary>
        /// GetDataBase ConnectionString by database type and connection string -- private use
        /// </summary>
        /// <param name="dataBaseType"></param>
        /// <param name="ConnString"></param>
        /// <returns></returns>
        private DbConnection GetDbConnection(Opt_DataBaseType dataBaseType, string ConnString)
        {
            switch (dataBaseType)
            {
            case Opt_DataBaseType.SqlServer:
                return(new SqlConnection(ConnString));

            case Opt_DataBaseType.MySql:
                return(new MySqlConnection(ConnString));

            case Opt_DataBaseType.Oracle:
                return(new OracleConnection(ConnString));

            default:
                return(new SqlConnection(ConnString));
            }
        }
 public DbCommandCommon(Opt_DataBaseType dataBaseType)
 {
     this.DbCommand = GetDbCommand(dataBaseType);
 }
 public SqlConnection_WR_Safe(Opt_DataBaseType dataBaseType, string ConnString_RW)
 {
     this.DbConnection = GetDbConnection(dataBaseType, ConnString_RW);
 }
Beispiel #9
0
 /// <summary>
 /// SetCurrentDbConnection
 /// </summary>
 /// <param name="connectionStr"></param>
 /// <param name="dataBaseType"></param>
 public static void SetCurrentDbConnection(string connectionStr, Opt_DataBaseType dataBaseType)
 {
     Db_Helper_DG.ConnString_Default     = connectionStr;
     Db_Helper_DG.dataBaseType           = dataBaseType;
     CommonVariables.currentDataBaseType = dataBaseType;
 }