I am trying to pull data from a long raw field in an oracle 11g database. However I keep getting “specified cast is not valid” when I try:
cmd.InitialLONGFetchSize = 1000000;
cmd.AddRowid = true;
byte[] PicTempArray = new Byte[1024];
Oracle.DataAccess.Client.OracleDataReader Reader = cmd.ExecuteReader();
int i = 0;
while (Reader.Read())
{
try
{
PicTempArray[i] = Reader.GetByte(0);
}
catch
{
}
i++;
}
I wouldnt be surprised if I was doing a few things wrong. If you didnt guess the LONG RAW is holding some image data. Any advice is appreciated.
GetByteis used to retrieve a single byte from a numeric column.You want
GetBytesinstead. You should probably also read the documentation for “Obtaining LONG and LONG RAW Data”.(As an aside, I hope you don’t really have an empty catch block – and your code would be more idiomatic if you used camelCase for your local variable names, and outdented the braces for the
tryandcatchblocks, as they are for thewhileblock.)