Article ID: 189948
Article Last Modified on 3/2/2005
Private Sub Command1_Click()
Dim ds As Object 'RDS.DataSpace.
Dim df As Object 'RDSServer.DataFactory.
Dim oRsCompound As adodb.Recordset 'Resultset.
Dim iCount As Integer ' Open compound recordset.
Dim sCn As String
Dim sSQL As String
sCn = "Provider=MSDASQL;dsn=localserver;uid=<username>;pwd=<strong password>;database=pubs"
sSQL = "SELECT * FROM authors; " & _
"SELECT * FROM stores; " & _
"SELECT * FROM jobs"
Set ds = CreateObject("RDS.DataSpace")
Set df = ds.CreateObject("RDSServer.DataFactory","http://localhost")
Set oRsCompound = df.Query(sCn, sSQL)
Do Until oRsCompound Is Nothing
Debug.Print "Contents of recordset #" & iCount
Do While Not oRsCompound.EOF
Debug.Print , oRsCompound.Fields(0), oRsCompound.Fields(1)
oRsCompound.MoveNext
Loop
Set oRsCompound = oRsCompound.NextRecordset
iCount = iCount + 1
Loop
End Sub
Private Sub Command2_Click()
Dim oRsCompound As adodb.Recordset
Dim iCount As Integer ' Open compound recordset.
Dim sCn As String
Dim sSQL As String
sCn = "Provider=SQLOLEDB;" & _
"Data Source=servername;" & _
"Initial Catalog=pubs;" & _
"User Id=<username>;Password=<strong password>;"
sSQL = "SELECT * FROM authors; " & _
"SELECT * FROM stores; " & _
"SELECT * FROM jobs"
Set oRsCompound = New adodb.Recordset
oRsCompound.CursorLocation = adUseClient
oRsCompound.Open sSQL, _
sCn, _
adOpenUnspecified, _
adLockUnspecified
'If next line is commented out it works.
Set oRsCompound.ActiveConnection = Nothing
Do Until oRsCompound Is Nothing
Debug.Print "Contents of recordset #" & iCount
Do While Not oRsCompound.EOF
Debug.Print , oRsCompound.Fields(0), _
oRsCompound.Fields(1)
oRsCompound.MoveNext
Loop
Set oRsCompound = oRsCompound.NextRecordset
iCount = iCount + 1
Loop
End Sub
Keywords: kbbug kbnofix kbdatabase KB189948