/// <summary>
        /// reload table in specific database
        /// </summary>
        /// <param name="db"></param>
        /// <param name="conn"></param>
        public static void ReloadTableList(this MySqlDatabaseInfo db, MySqlConnection conn, bool readTableDetail = false)
        {
            Use(db, conn);
            //-----------------------------------

            //To find out what tables the default database contains
            var cmd = new MySqlCommand("show tables", conn);
            List <MySqlTableInfo> tableInfoList = new List <MySqlTableInfo>();
            var reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                tableInfoList.Add(new MySqlTableInfo(reader.GetString(0))
                {
                    OwnerDatabase = db
                });
            }
            reader.Close();
            //-------------
            db.Tables = tableInfoList;
            if (readTableDetail)
            {
                foreach (MySqlTableInfo tbl in tableInfoList)
                {
                    tbl.ReloadColumnList(conn);
                }
            }
        }
 private void CreateMySqlDatabase_OnClick(object sender, RoutedEventArgs e)
 {
     try
     {
         var mySqlDatabaseInfo = new MySqlDatabaseInfo
         {
             ServerIp     = mySql_serverAddress.Text,
             ServerPort   = mySql_serverPort.Text,
             DatabasePath = mySql_databaseName.Text,
             Username     = mySql_username.Text,
             Password     = mySql_password.Text
         };
         mySqlDatabaseInfo.CreateDatabase();
         CreateSchema(mySqlDatabaseInfo);
         OpenSession(mySqlDatabaseInfo);
         MessageBox.Show(string.Format("Database {0} is created", sqlServer_databasePath.Text));
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error");
     }
 }
        public static void ReloadStoreFuncList(this MySqlDatabaseInfo db, MySqlConnection conn, bool readDetail = false)
        {
            Use(db, conn);
            //-----------------------------------
            //To find out what tables the default database contains
            var cmd = new MySqlCommand("show function status where db=?db", conn);
            List <MySqlStoreFuncInfo> storeFuncList = new List <MySqlStoreFuncInfo>();

            cmd.Parameters.AddWithValue("?db", db.Name);
            var reader = cmd.ExecuteReader();

            int ord_name    = reader.GetOrdinal("Name");
            int ord_type    = reader.GetOrdinal("Type");
            int ord_definer = reader.GetOrdinal("Definer");
            int ord_modifed = reader.GetOrdinal("Modified");
            int ord_created = reader.GetOrdinal("Created");

            while (reader.Read())
            {
                MySqlStoreFuncInfo storeProc = new MySqlStoreFuncInfo(reader.GetString("Name"));
                storeProc.OwnerDatabase = db;
                storeFuncList.Add(storeProc);
            }
            reader.Close();
            //-------------
            db.StoreFuncs = storeFuncList;

            //------------

            if (readDetail)
            {
                foreach (MySqlStoreFuncInfo func in storeFuncList)
                {
                    func.Sql = func.GetShowCreateStoreFunctionSql(conn);
                }
            }
        }
        /// <summary>
        /// set input db as current db, 'use' command
        /// </summary>
        /// <param name="db"></param>
        /// <param name="conn"></param>
        public static void Use(this MySqlDatabaseInfo db, MySqlConnection conn)
        {
            var cmd = new MySqlCommand("use " + db.Name, conn);

            cmd.ExecuteNonQuery();
        }