FIX: AV with SQLOLEDB Provider When PRINT Statement in Stored Procedure Returns More Than 512 Bytes of Data (294167)



The information in this article applies to:

  • Microsoft Data Access Components 2.5
  • Microsoft Data Access Components 2.5 SP1

This article was previously published under Q294167

SYMPTOMS

With the SQLOLEDB provider that ships with MDAC version 2.5 or 2.5 SP1, calling a Microsoft SQL Server stored procedure with one or more PRINT statements that return more than 512 bytes of data each may result in an access violation. The error message may be as follows:
The instruction at "0x7538127d" referenced memory at "0x3300400d". The memory could not be "read".

STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.

This problem was corrected in MDAC 2.6.

MORE INFORMATION

Steps to Reproduce Behavior

  1. Create the following stored procedure with a PRINT statement returning 700 bytes of data in the SQL Server Northwind database:
    CREATE PROCEDURE sp_Test2
    AS
    set nocount on
    declare @HTMLoutputx varchar(1000)
    select @HTMLoutputx = ''
    
    WHILE LEN(@HTMLoutputx) <= 700 
    BEGIN
    	select @HTMLoutputx = @HTMLoutputx + 'TOO MUCH TEXT IS BAD!'
    END
    
    PRINT @HTMLoutputx
    					
  2. Create a Microsoft Visual Basic standard EXE project and set the project reference to Microsoft ActiveX Data Objects 2.5 Library.
  3. Add the following function and call it in Form.Load:
    Function Test()
    
    On Error GoTo MAIN_ERROR
    
    Dim adocnn As ADODB.Connection
    Dim adocmd As ADODB.Command
    Dim adorst As ADODB.Recordset
       
    Set adocnn = New ADODB.Connection
    adocnn.CursorLocation = adUseClient
    adocnn.Open "Provider=SQLOLEDB;Data Source=vcdb;Database=northwind;uid=sa;pwd=;"
      
    Set adocmd = New Command
    With adocmd
        .CommandText = "sp_Test2"
        .CommandType = adCmdStoredProc
        .ActiveConnection = adocnn
    End With
    
    ' Execute the command.
    adocmd.Execute , , adExecuteNoRecords
    
    Set adocmd = Nothing
        
    adocnn.Close
    Set adocnn = Nothing
    
    Exit Function
    
    MAIN_ERROR:
       MsgBox Err & " - " & Error$, vbCritical, "CLASS:ReportCriteria,METHOD:LoadLists"
       Exit Function
    
    End Function
    					
  4. Run the code and you will see an access violation error returned.

Modification Type:MajorLast Reviewed:9/30/2003
Keywords:kbBug kbfix kbMDAC260fix KB294167