How to read a recordset file in VB6?
Posted on 2001-08-08
I am using VB6 and having trouble reading a recordset file created from an Access 97 database. The ExportData code below creates a file of what appears to be appropriate size. However, when I try to read the file in UpdateDB, the second line (rsInput.MoveFirst) generates error 3021, Either BOF or EOF is true. The size of the file indicates that records are there. I have used similar code in other programs successfully. What is wrong here?
Dim msFileName as String '-- name of quarterly export/import file
Dim mrsRun As New ADODB.Recordset '-- recordset for used to create file
Dim mrsInput As New ADODB.Recordset '-- recordset for to read data from file
Private Sub ExportData()
'-- export data to a recordset file
'-- assign file name
msFileName = "QData" & ".rs" '-- let extension show file type
'-- dump the data to a recordset
sSQL = "Select * from tblRun;"
Set mrsRun = New ADODB.Recordset
mrsRun.CursorType = adOpenDynamic
mrsRun.LockType = adLockOptimistic
mrsRun.CursorLocation = adUseClient
mrsRun.Open sSQL, gdbConnection
'-- save recordset as a file
'-- open input file
rsInput.Open msFileName, , , , adCmdFile 'This is the file created from tblRun
rsInput.MoveFirst <==== CRASHES HERE