Article ID: 154825
Article Last Modified on 7/1/2004
rdoEngine. rdoDefaultCursorDriver = rdUseODBC
- or -
rdoEnvironments(0).CursorDriver = rdUseOdbcThis option gives better performance for small result sets, but may degrade quickly for larger result sets depending on the Server and workstation configuration.
CREATE PROCEDURE TestMultiResults AS
select * from authors
select * from discounts
GO
Private Sub Form_Load()
Command1.Caption = "Run Stored Procedure"
End Sub
Private Sub Command1_Click()
Dim cn As rdoConnection
Dim ps As rdoPreparedStatement
Dim rs As rdoResultset
Dim strConnect As String
'set cursor driver to use server-side cursors
rdoDefaultCursorDriver = rdUseServer
'open a connection to the pubs database using DSNless connections
'Remember to change the following connection string parameters to reflect the correct values
strConnect = "Driver={SQL Server}; Server=myServer; " & _
"Database=pubs; Uid=<username>; Pwd=<strong password>"
Set cn = rdoEnvironments(0).OpenConnection(dsName:="", _
Prompt:=rdDriverNoPrompt, _
ReadOnly:=False, _
Connect:=strConnect)
'create a prep stmt for the stored proc call
Set ps = cn.CreatePreparedStatement("MyPs", _
"{call TestMultiResults}")
'set the RowSet size to 1
ps.RowsetSize = 1
'open the resultset with forward-only cursor
Set rs = ps.OpenResultset(rdOpenForwardOnly)
'add the first resultset to a list box
While Not rs.EOF
list1.AddItem rs("au_fname") & " " & rs("au_lname")
rs.MoveNext
Wend
'move to the second resultset
rs.MoreResults
list1.AddItem "Second Resultset Below"
'add the second resultset to the same list box
While Not rs.EOF
list1.AddItem rs("discounttype") & " = " & rs("discount")
rs.MoveNext
Wend
'Close the resultset and the connection and set both to nothing
rs.Close
Set rs = Nothing
cn.Close
Set cn = Nothing
End Sub
Additional query words: kbVBp400 kbVBp500 kbVBp600 kbdse kbDSupport kbRDO kbVBp
Keywords: kbhowto kbrdo KB154825