我在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
我完全确定我的命令有结果行。我已经尝试记录sql命令,然后将其复制粘贴到sqltalk中,它完全符合我的预期 - 它有一行。
但在我的VB案例中,我有EOF和BOF总是=真。
为什么呢?以及如何解决这个问题?
答案 0 :(得分:0)
请检查记录集的属性cursorLocation和连接对象。我希望这能解决你的问题。
答案 1 :(得分:0)
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
好看......
-G。卡塞雷斯哥斯达黎加