I'm getting records from a MS Access database. The database decimal separator is comma and I can't change it. The value from the SQL result casted into Double return wrong value as it's not the same in the database, I guess because of different Cultures in the database and the code. I'm using Petapoco library.
There is probably a way to set the Culture into Petapoco but how ?
public class TExternalProp
{
public String ObjectID { get; set; }
public String ObjectTable { get; set; }
public String PropName { get; set; }
public int PropType { get; set; }
public String PropStringValue { get; set; }
public Double PropDoubleValue { get; set; }
public int PropIntValue { get; set; }
}
sql = Sql.Builder.Append("WHERE ObjectID=@0 AND ObjectTable=@1 AND PropType<>@2 ", this.box_CMSID, "TSelectiveBox", 4);
sql.Append("ORDER BY PropName ASC;");
foreach (TExternalProp item in petaDb.Fetch<TExternalProp>(sql))
{
myViewModel.ObCol_BoiteInstructions.set_values(item.PropName, item.PropType, item.PropStringValue, item.PropDoubleValue, item.PropIntValue);
}
Value in the database is 3.2, cast return 3.2000000476837158 in PropDoubleValue member. I need to get exactly the same value as it is in the database. Any idea ?
Solution :
MS Access Single Real = float type in C#. MS Access Double Real = double type in C#