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:
- 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.
- Use the following SQL to create a new stored procedure:
CREATE PROCEDURE "TestSProc"
AS
EXEC sp_help 'Customers'
Save the stored procedure.
- Run the stored procedure and note that one row is returned in Datasheet view.
- Open SQL Server Query Analyzer, connect to the NorthwindCS database on your SQL Server, and run the following code:
Note that approximately 23 rows are returned.