'ADODB recordset has always EOF and BOF as True while records exist
I have next code on Visual Basic 6:
Static cmd As ADODB.Command
Static rs As ADODB.Recordset
If cmd Is Nothing Then
Set rs = New ADODB.Recordset
rs.ActiveConnection = conn
Set cmd = New ADODB.Command
cmd .ActiveConnection = conn
cmd .CommandText = mySqlCommand
cmd .Prepared = True
AddParam cmd, "MyParam", myParam
End IF
SetParam cmd, "MyParam", myParam
rs.Open cmd, , adOpenForwardOnly, adLockReadOnly
While Not rs.EOF
'Some code...
'...
rs.MoveNext
Wend
rs.Close
I'm totally sure that my command has a result rows. I've tried to log sql command, and then copy-paste it into sqltalk, and it works exactly I've expected - it has a rows.
But in my case in VB I have EOF and BOF always = True.
Why? And how to fix this?
Solution 1:[1]
Please check the property cursorLocation for recordset and for connection object. I hope this will solve your problem.
Solution 2:[2]
While (rsSource.eof = False) And (StopOrShoot = False)
' bookmark must have less value that recordcount for use the command .movenext
' if have the same value and you use .movenext EOF gonna be TRUE and you can“t
' read the last row....
' you try it ...
If rsSource.RecordCount > rsSource.Bookmark Then
rsSource.MoveNext
Else
StopOrShoot = True
End If
Wend
Good look...
G. Caseres by Costa Rica
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Avi |
| Solution 2 |
