Microsoft KB Archive/232562

= ACC2000: Output of Stored Procedure Truncated in Access Client/Server =

Article ID: 232562

Article Last Modified on 6/23/2005

-

APPLIES TO


 * Microsoft Access 2000 Standard Edition

-



This article was previously published under Q232562



Advanced: Requires expert coding, interoperability, and multiuser skills.

This article applies only to a Microsoft Access project (.adp).



SYMPTOMS
When you run certain stored procedures from a Microsoft Access project, the output of the procedure is truncated in Datasheet view. If you run the same procedure from one of the SQL Server Client Tools, all rows are returned as expected.



CAUSE
If a stored procedure returns multiple result sets in its output, an Access project returns only the first result set to Datasheet view. The user interface in an Access project is not designed to return multiple result sets.



RESOLUTION
Use alternate tools to run stored procedures that return multiple result sets, such as SQL Server Query Analyzer or OSQL.



MORE INFORMATION
To determine if Access Client/Server can display the entire output of a particular stored procedure, follow these steps.

NOTE: The sample code in this article uses Microsoft ActiveX Data Objects. For this code to run properly, you must reference the Microsoft ActiveX Data Objects 2.x Library (where 2.x is 2.1 or later.) To do so, click References on the Tools menu in the Visual Basic Editor, and make sure that the Microsoft ActiveX Data Objects 2.x Library check box is selected.

Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.  Open an Access project that is connected to the user database which contains the stored procedure that you want to examine. If you need to test a system stored procedure, open any Access project connected to a user database.  Create a module and type the following line in the Declarations section if it is not already there: Option Explicit   Type the following procedure: Sub CheckOutput(strProcName As String) Dim conn As New adodb.Connection Dim com As New adodb.Command Dim rs As New adodb.Recordset Dim i  On Error GoTo errorTrapper Set conn = CurrentProject.Connection com.ActiveConnection = conn With com .CommandText = strProcName .CommandType = adCmdStoredProc End With Set rs = com.Execute Do Until rs Is Nothing i = i + 1 Set rs = rs.NextRecordset If i > 1 Then MsgBox "Stored Procedure " & strProcName & _ " contains more than one resultset. " & vbCrLf & _ "The results will therefore be truncated when displayed.", _ vbInformation Exit Sub End If  Loop Exit Sub errorTrapper: If Err.Number = 3251 Then MsgBox "Stored Procedure " & strProcName & _ " contains only one resultset. " & vbCrLf & _ "It therefore should be displayed correctly.", _ vbInformation Else MsgBox Err.Description & Err.Number, vbCritical, "Error" End If End Sub   Open the Immediate window and type the following line of code, substituting StoredProcName with the name of the stored procedure that you want to examine: Call Checkoutput("StoredProcName") Press ENTER. 

Steps to Reproduce Behavior
 Open an Access project connected to the sample database NorthwindCS.adp.</li>  Use the following SQL to create a new stored procedure: <pre class="fixed_text">  CREATE PROCEDURE "TestSProc" AS  EXEC sp_help 'Customers' Save the stored procedure.

</li> Run the stored procedure and note that one row is returned in Datasheet view.</li>  Open SQL Server Query Analyzer, connect to the NorthwindCS database on your SQL Server, and run the following code: EXEC TestSproc </li></ol>

Note that approximately 23 rows are returned.

<div class="references_section">