OleDbDataReader and Oracle

A

Arnie Mauer

Using VS 2005 and C# and the OleDb components. The OleDbConnection
works fine as does the OleDbCommand object with a simple select
against an Oracle 9i DB. However when The code below is executed on
the first row, I get an exception saying the number to be cast has to
be less than infinity. I know for a fact its 2. The column is
defined as a NUMBER(5) in Oracle. I've tried to 'Get' float, double,
value. All with the same result.

if (!q.IsDBNull(2))

short s = (short) q.GetInt16(2);

- Arnie
 
G

Guest

I don't use the OleDb provider, but I've heard from posters on other boards
that it is known to behave strangely at times. I use the .NET Oracle Client
that comes with frameworks 1.1 and have never had any problems.
 
R

Roy Fine

Arnie-

have a look at the type of the object that is stored in position 2 of the
collection - my guess is that it is not an object of type INT, but rather an
object of type DECIMAL. Try GetOracleDecimal(2).ToInt32() - or use the
explicit int cast operator...

regards
roy fine
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top