Hi there,
we switched to .Net Framework 4.0 and since Microsoft will no longer support their ADO .NET Client for Oracle we are about to change to devart. I did some tests and had the following problem:
In our code there are statements like
OracleDataReader reader;
....
decimal? val = reader["field"] as decimal?
The field is defined as NUMBER(15) in oracle. The MS version works perfektly and the correct value is assigned to the val variable. When using the same code with the devart provider the assigned value is NULL because reader["field"] is a double. When using reader.GetDecimal(i) on that field I get the correct result.
Is there a known solution to use the given code above?
Regards
Samas
Migration from MS ADO to DevArt DataProvider
-
- Devart Team
- Posts: 1710
- Joined: Thu 03 Dec 2009 10:48
By default, dotConnect for Oracle maps Number(15) into Double. This behaviour can be changed using the NumberMappings collection of your OracleConnection object:
For more information about this, please refer to
http://www.devart.com/dotconnect/oracle ... pings.html
Also, we've implemented the possibility to configure number mappings in the connection string; this feature will be available in the nearest build.
Code: Select all
OracleConnection con = new OracleConnection(ConnectionString);
con.Open();
con.NumberMappings.Add(new OracleNumberMapping(OracleNumberType.Integer, 15, typeof(System.Decimal)));
http://www.devart.com/dotconnect/oracle ... pings.html
Also, we've implemented the possibility to configure number mappings in the connection string; this feature will be available in the nearest build.
I dont have that OracleNumberMapping class in the installed devart assembly. I used the dcoracle570pro.exe package to install. The assembly version of Devart.Data.Oracle.dll is 5.70.170.0. The NumberMappings property exists but the Add() method needs one object as parameter.
The example at the devart documentation doesnt work either. There is only the Add() method with one parameter (of object)
oracleConnection.NumberMappings.Add(OracleNumberType.Integer, 10, 18, typeof(Int64));
Any idea whats wrong?
The example at the devart documentation doesnt work either. There is only the Add() method with one parameter (of object)
oracleConnection.NumberMappings.Add(OracleNumberType.Integer, 10, 18, typeof(Int64));
Any idea whats wrong?
Never mind. I found the error. The class name is not OracleNumberMapping but just NumberMapping. Using this one works perfectly.
Thanks for the hint.
So the example is :
Thanks for the hint.
So the example is :
Code: Select all
OracleConnection con = new OracleConnection(ConnectionString);
con.Open();
con.NumberMappings.Add(new NumberMapping(OracleNumberType.Integer, 15, typeof(System.Decimal)));
-
- Devart Team
- Posts: 1710
- Joined: Thu 03 Dec 2009 10:48
Glad to see that the problem was resolved.
The NumberMapping class was renamed to OracleNumberMapping in the 5.70.190 version of dotConnect for Oracle. Please note that 'OracleNumberMapping' will be used in future versions of dotConnect for Oracle as well.
You can download the 5.70.190 version or the latest 6.0.46 Beta build at
http://www.devart.com/dotconnect/oracle/download.html
(the trial only) or at Registered Users' Area (provided that you have an active subscription):
http://secure.devart.com/
The NumberMapping class was renamed to OracleNumberMapping in the 5.70.190 version of dotConnect for Oracle. Please note that 'OracleNumberMapping' will be used in future versions of dotConnect for Oracle as well.
You can download the 5.70.190 version or the latest 6.0.46 Beta build at
http://www.devart.com/dotconnect/oracle/download.html
(the trial only) or at Registered Users' Area (provided that you have an active subscription):
http://secure.devart.com/