SetDatabase() public method

public SetDatabase ( string dbName ) : void
dbName string
return void
Exemplo n.º 1
0
        /// <include file='docs/MySqlConnection.xml' path='docs/ChangeDatabase/*'/>
        public override void ChangeDatabase(string databaseName)
        {
            if (databaseName == null || databaseName.Trim().Length == 0)
            {
                Throw(new ArgumentException(Resources.ParameterIsInvalid, "databaseName"));
            }

            if (State != ConnectionState.Open)
            {
                Throw(new InvalidOperationException(Resources.ConnectionNotOpen));
            }

            // This lock  prevents promotable transaction rollback to run
            // in parallel
            lock (driver)
            {
#if !RT
                if (Transaction.Current != null &&
                    Transaction.Current.TransactionInformation.Status == TransactionStatus.Aborted)
                {
                    Throw(new TransactionAbortedException());
                }
#endif
                // We use default command timeout for SetDatabase
                using (new CommandTimer(this, (int)Settings.DefaultCommandTimeout))
                {
                    driver.SetDatabase(databaseName);
                }
            }
            this.database = databaseName;
        }
Exemplo n.º 2
0
        /// <include file='docs/MySqlConnection.xml' path='docs/ChangeDatabase/*'/>
        public override void ChangeDatabase(string database)
        {
            if (database == null || database.Trim().Length == 0)
            {
                throw new ArgumentException(Resources.ParameterIsInvalid, "database");
            }

            if (State != ConnectionState.Open)
            {
                throw new InvalidOperationException(Resources.ConnectionNotOpen);
            }

            driver.SetDatabase(database);
            settings.Database = database;
        }
Exemplo n.º 3
0
        /// <include file='docs/MySqlConnection.xml' path='docs/ChangeDatabase/*'/>
        public void ChangeDatabase(string databaseName)
        {
            if (databaseName == null || databaseName.Trim().Length == 0)
            {
                throw new ArgumentException(
                          Resources.GetString("ParameterIsInvalid"), "database");
            }

            if (state != ConnectionState.Open)
            {
                throw new InvalidOperationException(
                          Resources.GetString("ConnectionNotOpen"));
            }

            driver.SetDatabase(databaseName);
            settings.Database = databaseName;
        }
Exemplo n.º 4
0
        /// <include file='docs/MySqlConnection.xml' path='docs/ChangeDatabase/*'/>
        public override void ChangeDatabase(string databaseName)
        {
            if (databaseName == null || databaseName.Trim().Length == 0)
            {
                throw new ArgumentException("ResourceStrings.ParameterIsInvalid", "databaseName");
            }

            if (State != ConnectionState.Open)
            {
                throw new InvalidOperationException("ResourceStrings.ConnectionNotOpen");
            }

            // This lock  prevents promotable transaction rollback to run
            // in parallel
            lock (driver)
            {
                // We use default command timeout for SetDatabase
                using (new CommandTimer(this, (int)Settings.DefaultCommandTimeout))
                {
                    driver.SetDatabase(databaseName);
                }
            }
            this.database = databaseName;
        }