Retrieving a blob from Oracle using MS Enterprise Library 3.1 RRS feed

  • Question

  • User-1907412876 posted

    I currently have an Oracle stored procedure that returns a blob.

    We're using MS Enterprise Library 3.1 to connect to the database and I can't find any support for lobs at all.

    Anyone know if this is possible using the enterprise library?

    Wednesday, March 5, 2008 8:37 AM

All replies

  • User981234921 posted

    Not sure if this will help you or not, but I needed to pull a BLOB back into a byte array to write it to a file. What I did was to pull the BLOB back from the database in a DataReader and use GetBytes. The code below works for me, though it is not using a stored proc.

    using Microsoft.Practices.EnterpriseLibrary.Data.Oracle;
    using System;
    using System.Data;
    OracleDatabase db = new OracleDatabase(connectionString);
    IDataReader dataReader = db.ExecuteReader(CommandType.Text, sqlString);
    long blobLength = dataReader.GetBytes(0, 0, null, 0, 0);
    byte[] writeBuffer = new byte[blobLength];
    dataReader.GetBytes(0, 0, writeBuffer, 0, (int)blobLength);

    So now the BLOB is in a byte array and can be written out to a file or hopefully whatever you need. FYI, the GetBytes concept came from Michal Kozusznik's post. Hope this works for you.
    Wednesday, April 16, 2008 1:51 PM