Пример #1
0
        /// <include file='docs/MySqlConnection.xml' path='docs/Open/*'/>
        public void Open()
        {
            if (state == ConnectionState.Open)
            {
                throw new InvalidOperationException(
                          Resources.GetString("ConnectionAlreadyOpen"));
            }

            SetState(ConnectionState.Connecting);

            try
            {
                if (settings.Pooling)
                {
                    driver = MySqlPoolManager.GetConnection(settings);
                }
                else
                {
                    driver = Driver.Create(settings);
                }
            }
            catch (Exception)
            {
                SetState(ConnectionState.Closed);
                throw;
            }

            // if the user is using old syntax, let them know
            if (driver.Settings.UseOldSyntax)
            {
                Logger.LogWarning("You are using old syntax that will be removed in future versions");
            }

            SetState(ConnectionState.Open);
            driver.Configure(this);
            if (settings.Database != null && settings.Database.Length != 0)
            {
                ChangeDatabase(settings.Database);
            }
            hasBeenOpen = true;
        }