Thread: ASP.NET/VB6 Using Multiple Recordsets

VB6 Using Multiple Recordsets
http://www.4guysfromrolla.com/webtech/083101-1.shtml

'Create the SQL string
sSQL = "SELECT categoryId, categoryName FROM Categories WHERE categoryId > 3"
sSQL = sSQL & ";SELECT RegionId , RegionDescription FROM Region"
sSQL = sSQL & ";SELECT ShipperID, CompanyName, Phone FROM Shippers"

'Define our connection string
sConnectString = "DRIVER={sql server};SERVER=localhost;" & _
                 "DATABASE=northwind;UID=sa;PWD="

'Retrieve the multiple Recordsets
set oRS = Server.CreateObject("ADODB.Recordset")
oRs.Open SQL, sConnectString

'Work with the first Recordset (the Categories table)
Do While Not oRs.EOF
   '......some processing here   
   oRs.MoveNext
Loop

'Move to the next Recordset
Set oRS = oRS.NextRecordset()

'Work with the second Recordset (the Region table)
Do While Not oRs.EOF
   '......some processing here   
   oRs.MoveNext
Loop

'Clean up...
oRS.Close
Set oRS = Nothing