ACC2000: Output of Stored Procedure Truncated in Access Client/ServerID: Q232562
|
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.
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.
Use alternate tools to run stored procedures that return multiple result sets, such as SQL Server Query Analyzer or OSQL.
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 need to reference the Microsoft ActiveX Data Objects 2.1 Library.
Microsoft provides programming examples for illustration only, without warranty
either expressed or implied, including, but not limited to, the implied warranties of
merchantability and/or fitness for a particular purpose. This article assumes that you
are familiar with the programming language being demonstrated and the tools used to
create and debug procedures. Microsoft support professionals 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 needs. If you have limited
programming experience, you may want to contact a Microsoft Certified Solution Provider
or the Microsoft fee-based consulting line at (800) 936-5200. For more information about
Microsoft Certified Solution Providers, please see the following page on the World Wide Web:
http://www.microsoft.com/mcsp/For more information about the support options available from Microsoft, please see the following page on the World Wide Web:
http://www.microsoft.com/support/supportnet/overview/overview.asp
Option Explicit
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
Call Checkoutput("StoredProcName")
Press ENTER.
CREATE PROCEDURE "TestSProc"
AS
EXEC sp_help 'Customers'
Save the stored procedure.
EXEC TestSproc
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:
http://support.microsoft.com/download/support/mslfiles/sqlbol.exe
Additional query words: prb
Keywords : kbdta AccessCS
Version : WINDOWS:2000
Platform : WINDOWS
Issue type : kbprb
Last Reviewed: July 22, 1999