Hello,
The problem is I have two recordsets. I need to leave one open while I run another against it. I get an error due to the cursor location. I am writing out 1 header record with recordset rsHeader using Q1, and writing out multiple detail records using recordset rsDetail using Q2. Then looping until all Header records are read.
Here is my psuedo code.
Dim MyCon as new adodb.Connection
Dim rsHeader as new adodb.Recordset
Dim rsDetail as new adodb.Recordset
Dim Q1 as string
Dim Q2 as string
MyCon.Connectionstring = "dsn=database ,uid=me , pwd=me;"
MyCon.CommandTimeout = 0
MyCon.Open
rsHeader.cursorlocation = aduseclient
rsHeader.open (Q1), MyCon, adOpenKeyset, adLockOptimistic
Do Until rsHeader.EOF
rsHeader.MoveFirst
rsDetail.cursorlocation = aduseclient
rsDetail.open (Q1), MyCon, adOpenKeyset, adLockOptimistic
Do while rsHeader!KeyValue = rsDetail!KeyValue 'join
outfile.write 'write out header record
rsDetail.MoveNext
Loop
outfile.write 'write out detail records
rsHeader.MoveNext
Loop
rsHeader.Close
rsDetail.Close
MyCon.Close
rsHeader = Nothing
rsDetail = Nothing
MyCon = Nothing
End Sub
The problem seems to be with having two recordsets open at the same time and trying to use .CursorLocation for both.
Is there a better way to loop without having both recordsets open at the same time?? Or change the setting of the rs.open command??
I read my VB 6 advanced book and it explained DAO and recordsets very well, but did not show an example with two recordsets.
Any help would be greatly appreciated.
The problem is I have two recordsets. I need to leave one open while I run another against it. I get an error due to the cursor location. I am writing out 1 header record with recordset rsHeader using Q1, and writing out multiple detail records using recordset rsDetail using Q2. Then looping until all Header records are read.
Here is my psuedo code.
Dim MyCon as new adodb.Connection
Dim rsHeader as new adodb.Recordset
Dim rsDetail as new adodb.Recordset
Dim Q1 as string
Dim Q2 as string
MyCon.Connectionstring = "dsn=database ,uid=me , pwd=me;"
MyCon.CommandTimeout = 0
MyCon.Open
rsHeader.cursorlocation = aduseclient
rsHeader.open (Q1), MyCon, adOpenKeyset, adLockOptimistic
Do Until rsHeader.EOF
rsHeader.MoveFirst
rsDetail.cursorlocation = aduseclient
rsDetail.open (Q1), MyCon, adOpenKeyset, adLockOptimistic
Do while rsHeader!KeyValue = rsDetail!KeyValue 'join
outfile.write 'write out header record
rsDetail.MoveNext
Loop
outfile.write 'write out detail records
rsHeader.MoveNext
Loop
rsHeader.Close
rsDetail.Close
MyCon.Close
rsHeader = Nothing
rsDetail = Nothing
MyCon = Nothing
End Sub
The problem seems to be with having two recordsets open at the same time and trying to use .CursorLocation for both.
Is there a better way to loop without having both recordsets open at the same time?? Or change the setting of the rs.open command??
I read my VB 6 advanced book and it explained DAO and recordsets very well, but did not show an example with two recordsets.
Any help would be greatly appreciated.