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!

Specified cast is not valid exception

user516304Jun 20 2006 — edited Jun 21 2006
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
}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 19 2006
Added on Jun 20 2006
7 comments
7,116 views