Specified cast is not valid exception
I have the following C# code (cut down for the post) that causes an exception (Specified cast is not valid) when I attemp the GetInt32 method call. FILE_HDR is a BLOB and I can read it just fine with GetBytes. This also happens on something like TO_NUMBER(FILE_ID, 'XXXXXXXX'). It seems like things do not work well when you define a column as a function. I can do this same thing with the MySQLDataReader without any problem.
Can anyone tell me what I am doing wrong here?
Thanks
string SelectStatement = "select FILE_ID, DBMS_LOB.Getlength FILE_HDR)...."
Cmd.CommandText = SelectStatement;
Reader = Cmd.ExecuteReader();
if (!Reader.HasRows)
{
throw new Exception("Unit File List Query returned no rows");
}
else
{
totalBytes = 0;
int HeaderLengthColumnOrdinal = Reader.GetOrdinal("DBMS_LOB.Getlength(FILE_HDR)");
// Get the number of rows
while (Reader.Read())
{
RowCount++;
totalBytes += (Int64)Reader.GetInt32(HeaderLengthColumnOrdinal); <- EXCEPTION
}