Пример #1
0
        /// <summary>
        /// Initailize connection string prarams.
        /// </summary>
        public DBConnectionString(DatabaseTypes databaseType, ConnectionParameterNames parameterNames)
        {
            if (databaseType == DatabaseTypes.None)
            {
                throw new ArgumentException("constructor DBConnectionString. DataBase type can not be 'None'!");
            }

            // Plamen Kovandjiev 20100119. Change logics set parameterNames
            if (parameterNames == null || parameterNames.Empty)
            {
                throw new ArgumentException("constructor DBConnectionString. ParameterNames type can not be Null or Empty!");
            }

            _databaseType = databaseType;

            _additonUserAndPassword = true;
            _addMissingParameter    = true;

            OnChanged();

            _connectionString = string.Empty;

            _provider      = string.Empty;
            _server        = string.Empty;
            _database      = string.Empty;
            _user          = string.Empty;
            _password      = string.Empty;
            _otherSettings = string.Empty;

            // Get pameters name
            _parameterNames = parameterNames;
            //_parameterNames = DatabaseUtility.GetParameterName(databaseType);
        }
Пример #2
0
        /// <summary>
        /// Initializes a new instance of the DataLayerBase class.
        /// </summary>
        /// <param name="databaseType">Data base type and create this class</param>
        /// <param name="dbConnection">Connection specific SQL server type</param>
        /// <param name="parameterPrefix">Paramether prefix specific SQL server</param>
        /// <param name="parameterNames">Parameter names</param>
        protected DataLayerBase(DatabaseTypes databaseType, IDbConnection dbConnection, string parameterPrefix, ConnectionParameterNames parameterNames)
        {
            if (databaseType == DatabaseTypes.None)
            {
                throw new ArgumentException("constructor DataLayerBase(). DatabaseType can not be 'None'!");
            }

            _dataBaseType = databaseType;

            if (dbConnection == null)
            {
                throw new ArgumentNullException("dbConnection", "Can not be Null!");
            }
            _connection = dbConnection;

            _propertyBindingFlag = BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.Instance;

            // Create ConnectionString
            _connectionString          = new DBConnectionString(databaseType, parameterNames);
            _connectionString.Changed += new EventHandler(ConnectionString_Changed);

            _lastError = string.Empty;
            // This a default initialization
            //_reRaiseException = false;

            _keepConnection = true;

            _inNotReconnected = true;

            // Set specific Prameter prefix
            _paramPrefix = parameterPrefix;

            // Create command
            CreateCommand();
            // Set command type
            _command.CommandType = CommandType.Text;
            _defaultCommandType  = CommandType.Text;
        }