I have following situation. I have PL/SQL - where I clicked "Describe" button on table and it told me type of one column is "INTEGER". On the C# side I have this code to read that value:
// GET ID
if (!rdr.IsDBNull(rdr.GetOrdinal("ID")))
{
int ID = rdr.GetInt32(rdr.GetOrdinal("ID")); // Here I get exception
}
But I get this exception:
Specified cast is not valid.
Can anyone help?
Stack trace:
StackTrace " at Oracle.DataAccess.Client.OracleDataReader.GetInt32(Int32 i)\\r\\n at 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 is an alias for the
NUMBER(38)
data type, and is designed so that theOracleDataReader
returns aSystem.Decimal
or OracleNumber instead of an integer value. Using the .NET Framework data type can cause an overflow.
Looks like this mapped to decimal in .NET side and you need to use GetDecimal
method instead;
decimal ID = rdr.GetDecimal(rdr.GetOrdinal("ID"));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.