Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

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


View products that this article applies to.

This article was previously published under Q294167

↑ Back to the top


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".

↑ Back to the top


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.

↑ Back to the top


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.

↑ Back to the top


Keywords: KB294167, kbmdac260fix, kbfix, kbbug

↑ Back to the top

Article Info
Article ID : 294167
Revision : 3
Created on : 9/30/2003
Published on : 9/30/2003
Exists online : False
Views : 310