B
BLUE
DbParameter dateAndTime = this.factory.CreateParameter();
dateAndTime.ParameterName = "@DateAndTime";
dateAndTime.DbType = DbType.DateTime;
string utcDtString = nameValueCollection.Get("dateAndTime").TrimEnd('Z');
dateAndTime.Value = DateTime.ParseExact(utcDtString, "s",
CultureInfo.InvariantCulture);
NumberFormatInfo nfi = new NumberFormatInfo();
nfi.NumberDecimalSeparator = ".";
DbParameter latitude = this.factory.CreateParameter();
latitude.ParameterName = "@Latitude";
latitude.DbType = DbType.Decimal;
latitude.Value = decimal.Parse(nameValueCollection.Get("latitude"), nfi);
If I do not set datetime in this way it will not be stored as UTC but
converted to my local timezone.
If I set latitude value with a string it gives me an error since I'm in
Italy and here the comma is used instead of the dot in decimal numbers.
Why using Parameters if I have to do all this work?
I can simply check fields before doing a query and then building the query
with "+" concatenation operator.
Thanks,
Luigi.
dateAndTime.ParameterName = "@DateAndTime";
dateAndTime.DbType = DbType.DateTime;
string utcDtString = nameValueCollection.Get("dateAndTime").TrimEnd('Z');
dateAndTime.Value = DateTime.ParseExact(utcDtString, "s",
CultureInfo.InvariantCulture);
NumberFormatInfo nfi = new NumberFormatInfo();
nfi.NumberDecimalSeparator = ".";
DbParameter latitude = this.factory.CreateParameter();
latitude.ParameterName = "@Latitude";
latitude.DbType = DbType.Decimal;
latitude.Value = decimal.Parse(nameValueCollection.Get("latitude"), nfi);
If I do not set datetime in this way it will not be stored as UTC but
converted to my local timezone.
If I set latitude value with a string it gives me an error since I'm in
Italy and here the comma is used instead of the dot in decimal numbers.
Why using Parameters if I have to do all this work?
I can simply check fields before doing a query and then building the query
with "+" concatenation operator.
Thanks,
Luigi.