Question : Read BLOB data from oracle through a stored procedure

I have a column with blob data type in the oracle data base. i wrote a stored procedure which take an id value as in parameter and give blob value as out parameter.
From .net side i use the following code

OracleConnection conn = new OracleConnection(connnectionstring);
            OracleCommand cmd = new OracleCommand();
            cmd.Connection = conn;
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = procedure;
            cmd.Parameters.Add("SEQ_NO", OracleType.VarChar).Value = key;
            cmd.Parameters.Add("FILE_DATA", OracleType.Blob).Direction = ParameterDirection.Output;
            try
            {
                conn.Open();
                cmd.ExecuteNonQuery();
                conn.Close();
            }
            catch
            {

            }
            filedata = (byte[])cmd.Parameters["FILE_DATA"].Value;
            return filedata;

Its giving me error that it con not convert oraclelob to byte[].
Any ideas please

Answer : Read BLOB data from oracle through a stored procedure

Hi psdeepu545,

I modified your code based on the example at http://www.akadia.com/services/dotnet_orablobs.html:
(the code is not tested)
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
// Cast BLOB data using OracleBlob type
OracleBlob blob = (OracleBlob)cmd.Parameters["FILE_DATA"].Value;

// Create a byte array of the size of the Blob obtained
Byte[] filedata =  new Byte[blob.Length];

// Read blob data into byte array
blob.Read(filedata,0,System.Convert.ToInt32(blob.Length));

return filedata;
Random Solutions  
 
programming4us programming4us