PRB: E_UNEXPECTED Returned from IRowsetChange::DeleteRows Without Releasing ISequentialStream Pointer (236828)



The information in this article applies to:

  • Microsoft OLE DB Provider for SQL Server 7.01
  • Microsoft OLE DB Provider for SQL Server 7.0
  • Microsoft OLE DB, when used with:
    • Microsoft Visual C++ .NET (2002)
    • Microsoft Visual C++ .NET (2003)
    • Microsoft Visual C++, 32-bit Enterprise Edition 6.0
    • Microsoft Visual C++, 32-bit Professional Edition 6.0
    • Microsoft Visual C++, 32-bit Learning Edition 6.0

This article was previously published under Q236828

SYMPTOMS

When you use the Microsoft SQL Server OLE DB provider (SQLOLEDB), the following error is returned from IRowsetChange::DeleteRows():
HRESULT = E_UNEXPECTED Description = "Catastrophic error"

CAUSE

A pointer to an ISequentialStream interface has been retrieved on the row and has not been released.

RESOLUTION

Release all ISequentialStream pointers on the row before you delete the row with IRowsetChange::DeleteRows.

STATUS

This behavior is by design.

MORE INFORMATION

Steps to Reproduce the Behavior

  1. Create a table in SQL Server with an image field.

    Table Name: DemoTab

    Field Name Data Type
    field1int
    field2image
  2. Use the Active Template Library (ATL) OLE DB Consumer Wizard to create a CCommand class that will be used to open up a rowset on the table. The wizard will generate code similar to the following in the accessor class:
    	BLOB_ENTRY(2, IID_ISequentialStream, STGM_READ, m_field2)
    					
    Note In Visual C++ .NET, the wizard generates code for using the ISequentialStream object in comments. If you want to use this object, you must uncomment these lines in the generated code. The accessor class will be similar to the following:
    BLOB_ENTRY_LENGTH_STATUS(2, IID_ISequentialStream, STGM_READ, m_field2, m_dwfield2Length, m_dwfield2Status)
    					
  3. Using the new CCommand derived class, add the following:
    HRESULT hr;
       CMyCommand rs;
       rs.Open();
       rs.MoveNext();<BR/>
    // rs.m_field2->Release(); //un-comment these two lines to fix the error 
    //rs.m_field2 = NULL;
       hr = rs.Delete(); 
    					
    You will notice that E_UNEXPECTED is returned from the Delete() call.

Modification Type:MajorLast Reviewed:1/6/2004
Keywords:kbDatabase kbDTL kbprb kbProvider KB236828 kbAudDeveloper