Microsoft KB Archive/269412

= FIX: Access Violation Occurs When You Call SQL Server Stored Procedure That Contains PRINT Statement =

Article ID: 269412

Article Last Modified on 10/3/2003

-

APPLIES TO


 * Microsoft OLE DB Provider for SQL Server 7.0
 * Microsoft OLE DB Provider for SQL Server 7.01
 * Microsoft Data Access Components 2.5
 * Microsoft Data Access Components 2.5 Service Pack 1
 * Microsoft Data Access Components 2.5 Service Pack 2
 * Microsoft Data Access Components 2.5 Service Pack 3

-



This article was previously published under Q269412



SYMPTOMS
An access violation occurs when you call a SQL Server stored procedure that contains a PRINT statement that displays a string containing approximately 700 characters.

This occurs with the Microsoft OLE DB Provider for SQL Server (SQLOLEDB).



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.

You can download MDAC 2.6 or later from the following Web address:

http://msdn.microsoft.com/dataaccess



Steps to Reproduce Behavior
  Use the following SQL script to create a stored procedure that returns 700 bytes in a PRINT statement: CREATE PROCEDURE sp_Test2 AS set nocount on declare @HTMLoutputx varchar(1000) select @HTMLoutputx = ''

/* Create a text string containing more than 700 bytes. */ WHILE LEN(@HTMLoutputx) <= 700 BEGIN select @HTMLoutputx = @HTMLoutputx + 'TOO MUCH TEXT IS BAD!' END PRINT @HTMLoutputx  Create a new Standard EXE project in Visual Basic. Set a Project Reference to the Microsoft ActiveX Data Objects 2.5 Library.  Add a command button named Command1 and insert the following code for the Click event handler: Private Sub Command1_Click

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 &quot;Provider=SQLOLEDB;Data Source=myServer;Database=northwind;uid=sa;pwd=;&quot; Set adocmd = New ADODB.Command With adocmd .CommandText = &quot;sp_Test2&quot; .CommandType = adCmdStoredProc .ActiveConnection = adocnn End With

' Execute the command adocmd.Execute, , adExecuteNoRecords

Set adocmd = Nothing adocnn.Close Set adocnn = Nothing

Exit Sub

MAIN_ERROR: MsgBox Err & &quot; - &quot; & Error$, vbCritical, &quot;Error!&quot; Exit Sub

End Sub  Run the application. Click Command1 to see the access violation occur.

<div class="references_section">