public static List <CountryLanguage> GetAllCountryInfo()
        {
            List <CountryLanguage> allCountryLangInfo = new List <CountryLanguage> {
            };
            MySqlConnection conn = DB.Connection();

            conn.Open();
            MySqlCommand cmd = conn.CreateCommand() as MySqlCommand;

            cmd.CommandText = @"SELECT * FROM countrylanguage";
            MySqlDataReader rdr = cmd.ExecuteReader() as MySqlDataReader;

            while (rdr.Read())
            {
                string CountryCode           = rdr.GetString(0);
                string CountryLanguageType   = rdr.GetString(1);
                bool   CountryIsOfficialLang = rdr.GetBoolean(2);
                int    CountryLangPercentage = rdr.GetInt32(3);

                CountryLanguage newCountryLanguage = new CountryLanguage(CountryCode, CountryLanguageType, CountryIsOfficialLang, CountryLangPercentage);

                allCountryLangInfo.Add(newCountryLanguage);
            }

            conn.Close();

            if (conn != null)
            {
                conn.Dispose();
            }
            return(allCountryLangInfo);
        }
Example #2
0
        public static List <CountryLanguage> GetAll()
        {
            List <CountryLanguage> allLanguages = new List <CountryLanguage> {
            };
            MySqlConnection conn = DB.Connection();

            conn.Open();
            MySqlCommand cmd = conn.CreateCommand() as MySqlCommand;

            cmd.CommandText = @"SELECT * FROM countrylanguage;";
            MySqlDataReader rdr = cmd.ExecuteReader() as MySqlDataReader;

            while (rdr.Read())
            {
                string          Code        = rdr.GetString(0);
                string          Language    = rdr.GetString(1);
                float           Percentage  = rdr.GetFloat(3);
                CountryLanguage newLanguage = new CountryLanguage(Code, Language, Percentage);
                allLanguages.Add(newLanguage);
            }
            conn.Close();
            if (conn != null)
            {
                conn.Dispose();
            }
            return(allLanguages);
        }