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.

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


View products that this article applies to.

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.

↑ Back to the top


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.

↑ Back to the top


Resolution

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

↑ Back to the top


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.
  1. 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.
  2. Create a module and type the following line in the Declarations section if it is not already there:
    Option Explicit
    					
  3. 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
    					
  4. 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

  1. Open an Access project connected to the sample database NorthwindCS.adp.
  2. Use the following SQL to create a new stored procedure:
       CREATE PROCEDURE "TestSProc"
       AS
       EXEC sp_help 'Customers'
    					
    Save the stored procedure.

  3. Run the stored procedure and note that one row is returned in Datasheet view.
  4. Open SQL Server Query Analyzer, connect to the NorthwindCS database on your SQL Server, and run the following code:
    EXEC TestSproc
    					
Note that approximately 23 rows are returned.

↑ Back to the top


References

For more information about rules, SQL Server Query Analyzer, or OSQL, refer to SQL Server 7.0 Books Online, which is available for download from the following Microsoft Web site:

↑ Back to the top


Keywords: KB232562, kbclientserver, kbprb, kbdownload

↑ Back to the top

Article Info
Article ID : 232562
Revision : 3
Created on : 6/23/2005
Published on : 6/23/2005
Exists online : False
Views : 360