Migration from MS ADO to DevArt DataProvider

Migration from MS ADO to DevArt DataProvider

Postby samas » Fri 19 Nov 2010 09:40

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
samas
 
Posts: 3
Joined: Mon 31 Aug 2009 06:13

Postby StanislavK » Fri 19 Nov 2010 17:23

By default, dotConnect for Oracle maps Number(15) into Double. This behaviour can be changed using the NumberMappings collection of your OracleConnection object:
Code: Select all
OracleConnection con = new OracleConnection(ConnectionString);
con.Open();
con.NumberMappings.Add(new OracleNumberMapping(OracleNumberType.Integer, 15, typeof(System.Decimal)));

For more information about this, please refer to
http://www.devart.com/dotconnect/oracle/docs/Devart.Data.Oracle~Devart.Data.Oracle.OracleConnection~NumberMappings.html
Also, we've implemented the possibility to configure number mappings in the connection string; this feature will be available in the nearest build.
StanislavK
Devart Team
 
Posts: 1710
Joined: Thu 03 Dec 2009 10:48

Postby samas » Mon 22 Nov 2010 08:29

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?
samas
 
Posts: 3
Joined: Mon 31 Aug 2009 06:13

Postby samas » Mon 22 Nov 2010 08:46

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 :


Code: Select all
OracleConnection con = new OracleConnection(ConnectionString);
con.Open();
con.NumberMappings.Add(new NumberMapping(OracleNumberType.Integer, 15, typeof(System.Decimal)));
samas
 
Posts: 3
Joined: Mon 31 Aug 2009 06:13

Postby StanislavK » Mon 22 Nov 2010 12:04

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/
StanislavK
Devart Team
 
Posts: 1710
Joined: Thu 03 Dec 2009 10:48


Return to dotConnect for Oracle