We have encountered a very strange error with dotconnect. When retrieving -4.6 from the database it actually returns -4.6000000000000005 of type Double. Obviously there's some miscalculation taking place.
So far -4.6 is the magic number; no others found. This happens when using a dataContext/LINQ to Oracle and when just using a devart.data.oracle.oracleCommand object. The DataContext designer defaulted our field to type Double? instead of type Decimal, so we just left it that way.
dotConnect version: 5.35.79pro
oracle version: 10g
database field type: NUMBER, length 11, scale 2, nullable
Thanks,
Zach
-4.6 returns as -4.6000000000000005
Oracle performed these calculations. One can't expect the precise value when using Double, see the documentaton:
http://msdn.microsoft.com/en-us/library ... ouble.aspx
http://msdn.microsoft.com/en-us/library ... ouble.aspx
I am having the same problem
Hi, i am having the same problem (same DevArt version) but not with LINQ, but with TypedDataSet. The problem is that the dataset update command does not work, because when it compares original values in the where clause, the values don't match so the update returns 0 rows updated. This ends up in an error being thrown.
I am using the DbMonitor and everything looks fine but when i debug it, i see the real values and they look like this:
1.021 ---> 1.0210000000000001
Is there a way to solve this.
I am using the DbMonitor and everything looks fine but when i debug it, i see the real values and they look like this:
1.021 ---> 1.0210000000000001
Is there a way to solve this.
-
- Devart Team
- Posts: 2420
- Joined: Wed 02 Nov 2011 09:44
You can use the NumberMappings property of OracleConnection.
Where 1 and 20 are the lower and upper bounds of the Number precision used for this mapping rule.
If it is necessary, you can change the bounds of mapping to Decimal.
Please tell us if this helps.
Code: Select all
OracleConnection conn = new OracleConnection("Your ConnectionString");
conn.NumberMappings = new NumberMappingCollection();
NumberMapping nm = new NumberMapping(OracleNumberType.Number, 1, 20, typeof(Decimal));
conn.NumberMappings.Add(nm);
If it is necessary, you can change the bounds of mapping to Decimal.
Please tell us if this helps.