Skip to Main Content

ODP.NET

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Data Type Madness

433883Jan 13 2005 — edited Jan 17 2005
Hello,

I am writing an app in ASP.NET and C# using ODP.NET and the converting back and forth of data types is driving me mad.

The first question I have is do people know of any really good treatment of this subject specifically for the ODP.NET/ASP.NET&C# ?

Documentation like this:
http://download-east.oracle.com/docs/html/B10961_01/features.htm#1025224
... would have you believe that when you pass a number back from a stored proc, and you do:
using Oracle.DataAccess.Client;
etc...
OracleParameter outputParam = command.Parameters.Add("thisVal", OracleDbType.Int16);

... that documentation .NET has a matching Int16 datatype. Not so. You have to do .NET type of "short". You can sort of get this if you go crawling through the .NET documentation and borrow from their oracle provider.

To make matters more confusing, it isn't consistent. At times I have been able to use OracleDbType.Int32 only by typing it with decimal:
return (decimal)outputParam.Value;

Now I am doing another proc and returning a varchar2:
OracleParameter outputParam = command.Parameters.Add("loginId", OracleDbType.Varchar2, 30);

... in Toad the proc runs fine and returns in this case a string like TGH2345G. When I go to output in asp.net/c#:
return (string)outputParam.Value;
.... it a get this error:
"Specified cast is not valid."

I don't mind following rules, but I can't find any place to get the hard and fast "real" rules on this stuff.

Help!!

Thank you,

Kyle
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 14 2005
Added on Jan 13 2005
2 comments
452 views