Hi All,
I created a class that extracts blobs from an oracle table. I was able to achieve this using the snippet below:
string proc = " SELECT lobloc blob, a.filename fil_name, a.filesize fil_size " +
" FROM streamdata s, applicationdata a " +" WHERE s.ida2a2 = a.ida3a5 AND s.ida2a2 = 1767210 ";OracleCommand ocmd = new OracleCommand();
ocmd.CommandText = proc;
ocmd.Connection = con;
ocmd.CommandType =
CommandType.Text;
OracleDataReader odr = ocmd.ExecuteReader();
using (odr)
{
while (odr.Read()) {
OracleBlob blob = odr.GetOracleBlob(0);
byte[] byteData = new byte(blob.Value);
int ArraySize = new int();
ArraySize = byteData.GetUpperBound(0);
string DestinationLoc = "C:/FileServer/" + odr["fil_name"].ToString();FileStream fs1 = new FileStream(DestinationLoc, FileMode.OpenOrCreate, FileAccess.Write);
fs1.Write(byteData, 0, ArraySize);
fs1.Close();
}
}
ocmd.Parameters.Clear();
This generated a file but it seemed to be corrupted when opened. Can somebody pinpoint what I am doing wrong in my code? Thanks.