Fix 1 for serialization - more problems ahead

This commit is contained in:
Rick Falkvinge
2012-11-05 12:48:04 +00:00
parent 6af0345ebc
commit beb4b5af7f
3 changed files with 7 additions and 5 deletions
+2 -2
View File
@@ -20,7 +20,7 @@ namespace Activizr.Database
{
int countryId = reader.GetInt32(0);
string name = reader.GetString(1);
string code = reader.GetString(2);
string code = reader.GetString(2).ToUpperInvariant();
string culture = reader.GetString(3);
int geographyId = reader.GetInt32(4);
@@ -39,7 +39,7 @@ namespace Activizr.Database
connection.Open();
DbCommand command =
GetDbCommand("SELECT " + countryFieldSequence + " WHERE Code='" + countryCode.Replace("'", "''") + "'",
GetDbCommand("SELECT " + countryFieldSequence + " WHERE Code='" + countryCode.ToUpperInvariant().Replace("'", "''") + "'",
connection);
using (DbDataReader reader = command.ExecuteReader())
+2 -2
View File
@@ -14,7 +14,7 @@ namespace Activizr.Database
#region Field reading code
private const string postalCodeFieldSequence =
" PostalCodes.PostalCode,Cities.CityName,Countries.CountryCode " +
" PostalCodes.PostalCode,Cities.CityName,Countries.Code AS CountryCode " +
" FROM PostalCodes " +
" JOIN Cities ON (PostalCodes.CityId=Cities.CityId) " +
" JOIN Countries ON (PostalCodes.CountryId=Countries.CountryId) ";
@@ -42,7 +42,7 @@ namespace Activizr.Database
DbCommand command =
GetDbCommand(
"SELECT" + postalCodeFieldSequence + "WHERE Countries.CountryCode='" + countryCode.Replace("'", "''") + "';", connection);
"SELECT" + postalCodeFieldSequence + "WHERE Countries.Code='" + countryCode.Replace("'", "''") + "';", connection);
using (DbDataReader reader = command.ExecuteReader())
{
+3 -1
View File
@@ -207,11 +207,13 @@ namespace Activizr.Database
public BasicCity[] GetCitiesByCountry(string countryCode)
{
BasicCountry country = GetCountry(countryCode);
using (DbConnection connection = GetMySqlDbConnection())
{
connection.Open();
DbCommand command = GetDbCommand("SELECT " + cityFieldSequence + " WHERE CountryCode='" + countryCode.ToUpperInvariant().Replace("'", "''") + "'",
DbCommand command = GetDbCommand("SELECT " + cityFieldSequence + " WHERE CountryId=" + country.CountryId.ToString(),
connection);
List<BasicCity> result = new List<BasicCity>();
using (DbDataReader reader = command.ExecuteReader())