ExecuteArray with Stream object

ExecuteArray with Stream object

Postby eekstein » Mon 10 Oct 2011 19:03

I am using the ExecuteArray and have a class that is a subclass of a Stream. The class also implements IConvertible. I implemented the GetTypeCode method to return TypeCode.Object. Then I implemented the ToType method to return a byte array of the Stream. The ExecuteArray does call the GetTypeCode method but does not seem to call the ToType method, instead I get an "Unknown type" error in OracleValue (I inspected it through Quick Watch).

I am adding the parameter as a type OracleDBType.Blob...
Code: Select all
new OracleParameter("myImage", OracleDbType.Blob, ParameterDirection.Input)
   Value = value

What is the appropriate way to include a Stream as a column in theExecuteArray?
Posts: 3
Joined: Tue 13 Sep 2011 15:23

Postby Shalex » Tue 18 Oct 2011 14:01

I cannot reproduce the problem with cmd.ExecuteArray() and OracleLobs using the code below. If it doesn't help, please send us a small test project with the corresponding DDL/DML script to reproduce the issue in our environment.
Code: Select all
    using (OracleConnection conn = new OracleConnection()) {
        conn.ConnectionString = "server=orcl1120;uid=***;pwd=***;";

        FileStream fs = new FileStream("D:\Temp\foto.jpg", FileMode.Open, FileAccess.Read);
        BinaryReader r = new BinaryReader(fs);
        //Create temporary BLOB
        OracleLob myLob = new OracleLob(conn, OracleDbType.Blob);
        int streamLength = (int)fs.Length;
        //Transfer data to server
        myLob.Write(r.ReadBytes(streamLength), 0, streamLength);

        OracleCommand cmd = conn.CreateCommand();

        // Set command text property
        cmd.CommandText = "INSERT INTO blob_table VALUES(:blobcolumn, :id)";

        // Add parameters to command parameters collection
        cmd.Parameters.Add("blobcolumn", OracleDbType.Blob);
        cmd.Parameters.Add("id", OracleDbType.Integer);

        // Set parameters values
        cmd.Parameters["blobcolumn"].OracleValue = new OracleLob[] { myLob, myLob };
        cmd.Parameters["id"].Value = new int[] { 1,2 };
        // Insert two records at one time

For more information, refer to
http://www.devart.com/dotconnect/oracle ... yBind.html
Devart Team
Posts: 7654
Joined: Thu 14 Aug 2008 12:44

Return to dotConnect for Oracle