c# - Specified cast is not valid - exception -


i have following situation. have pl/sql - clicked "describe" button on table , told me type of 1 column "integer". on c# side have code read value:

    // id    if (!rdr.isdbnull(rdr.getordinal("id")))    {       int id =  rdr.getint32(rdr.getordinal("id")); // here exception    } 

but exception:

specified cast not valid.

can help?

stack trace:

stacktrace " @ oracle.dataaccess.client.oracledatareader.getint32(int32 i)\r\n @ gatewayfileimporter.form1.button1_click(object sender, eventargs e) in c:\users\g\documents\visual studio 2012\projects\fileimpo\fileimpo\form1.cs:line 86" string

from oracle data type mappings

this data type alias number(38) data type, , designed oracledatareader returns system.decimal or oraclenumber instead of integer value. using .net framework data type can cause overflow.

looks mapped decimal in .net side , need use getdecimal method instead;

decimal id =  rdr.getdecimal(rdr.getordinal("id")); 

Comments

Popular posts from this blog

How to provide Authorization & Authentication using Asp.net, C#? -

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

How to use Authorization & Authentication in Asp.net, C#? -