问题
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.
回答1:
GetByte is used to retrieve a single byte from a numeric column.
You want GetBytes instead. 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 try and catch blocks, as they are for the while block.)
来源:https://stackoverflow.com/questions/8014913/retrieving-a-byte-array-from-a-long-raw-from-oracle-db