我有关于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总是= True。
为什么?如何解决这个问题呢?
发布于 2013-07-20 23:20:05
请检查记录集和连接对象的属性cursorLocation。我希望这能解决你的问题。
发布于 2014-03-22 06:05:57
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. Caseres由哥斯达黎加提供
https://stackoverflow.com/questions/17090952
复制相似问题