public static DataTable GetAddressFromDB()
{
string MyConString = "server=192.168.2.213;database=hotel;Username=root;Password=crawl;";
MySqlConnection conn = new MySqlConnection(MyConString);
MySqlCommand command = conn.CreateCommand();
string dbQuery = String.Format(@"SELECT
suburb_city_id as SuburbCityId,
LOWER(TRIM(suburb_city_name)) as SuburbCityName,
LOWER(TRIM(main_country_state.state_name)) as StateName,
LOWER(TRIM(main_country.country_name)) as CountryName
FROM main_suburb_city
LEFT JOIN main_country_state
ON main_country_state.state_id = main_suburb_city.state_id
LEFT JOIN main_country
ON main_country.country_id = main_suburb_city.country_id
ORDER BY main_suburb_city.suburb_city_name;");
MySqlCommand cmd = new MySqlCommand(dbQuery, conn);
MySqlDataAdapter adapter = new MySqlDataAdapter();
adapter.SelectCommand = cmd;
DataTable dt = new DataTable();
adapter.Fill(dt);
conn.Close();
return dt;
}
{
string MyConString = "server=192.168.2.213;database=hotel;Username=root;Password=crawl;";
MySqlConnection conn = new MySqlConnection(MyConString);
MySqlCommand command = conn.CreateCommand();
string dbQuery = String.Format(@"SELECT
suburb_city_id as SuburbCityId,
LOWER(TRIM(suburb_city_name)) as SuburbCityName,
LOWER(TRIM(main_country_state.state_name)) as StateName,
LOWER(TRIM(main_country.country_name)) as CountryName
FROM main_suburb_city
LEFT JOIN main_country_state
ON main_country_state.state_id = main_suburb_city.state_id
LEFT JOIN main_country
ON main_country.country_id = main_suburb_city.country_id
ORDER BY main_suburb_city.suburb_city_name;");
MySqlCommand cmd = new MySqlCommand(dbQuery, conn);
MySqlDataAdapter adapter = new MySqlDataAdapter();
adapter.SelectCommand = cmd;
DataTable dt = new DataTable();
adapter.Fill(dt);
conn.Close();
return dt;
}
No comments:
Post a Comment