private void dbList_DropDown(object sender, EventArgs e)
 {
     if (!this.dbListPopulated)
     {
         DbConnectionStringBuilder builder = ((base.ConnectionProperties) as MySqlConnectionProperties).ConnectionStringBuilder;
         try
         {
             using (MySqlConnectionSupport support = new MySqlConnectionSupport())
             {
                 support.Initialize(null);
                 support.ConnectionString = builder.ConnectionString;
                 support.Open(false);
                 this.dbList.Items.Clear();
                 using (DataReader reader = support.Execute("SHOW DATABASES", 1, null, 0))
                 {
                     while (reader.Read())
                     {
                         string str = reader.GetItem(0).ToString().ToLowerInvariant();
                         if (!(str == "information_schema") && !(str == "mysql"))
                         {
                             this.dbList.Items.Add(reader.GetItem(0));
                         }
                     }
                     this.dbListPopulated = true;
                 }
             }
         }
         catch (Exception)
         {
             MessageBox.Show("Unable to retrieve the list of databases");
         }
     }
 }
Esempio n. 2
0
        internal static List <string> GetSchemas(MySqlConnectionStringBuilder csb)
        {
            var schemas = new List <string>();

            try
            {
                using (MySqlConnectionSupport conn = new MySqlConnectionSupport())
                {
                    conn.Initialize(null);
                    conn.ConnectionString = csb.ConnectionString;
                    conn.Open(false);
                    using (DataReader reader = conn.Execute("SHOW DATABASES", 1, null, 0))
                    {
                        while (reader.Read())
                        {
                            string dbName = reader.GetItem(0).ToString().ToLowerInvariant();
                            if (dbName == "performance_schema")
                            {
                                continue;
                            }
                            if (dbName == "information_schema")
                            {
                                continue;
                            }
                            if (dbName == "mysql")
                            {
                                continue;
                            }
                            schemas.Add(dbName);
                        }
                    }
                }
                return(schemas);
            }
            catch
            {
                return(null);
            }
        }