DAO.Recordset 在 codese 中执行时仅返回一条记录
该语句每次执行时总是只返回一条记录,
Dim rs As DAO.Recordset
Set rs = CurrentDb.OpenRecordset("Select book_name from book")
Dim i As Integer
For i = 0 To rs.RecordCount - 1
lbBooks.AddItem rs!book_name
rs.MoveNext
Next
这可能是什么原因
This statement always returns only one record everytime when its executed
Dim rs As DAO.Recordset
Set rs = CurrentDb.OpenRecordset("Select book_name from book")
Dim i As Integer
For i = 0 To rs.RecordCount - 1
lbBooks.AddItem rs!book_name
rs.MoveNext
Next
what could ebe the cause
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我相信
Recordset
的RecordCount
属性会动态设置为从游标读取的数据量。即第一次打开时设置为1;如果您执行rs.MoveLast
,它会将其设置为集合中的实际记录数。但是,您会遇到返回到开头的问题:您必须以特定模式打开记录集(我忘记了,从头到尾)才能任意前后移动光标指针。迭代游标的常用方法是使用 while 循环,检查游标的文件末尾:
I believe that the
RecordCount
property of aRecordset
is set dynamically to the amount of data that has been read from the cursor. That is, when it's first opened, it's set to 1; if you dors.MoveLast
, it will set it to the actual number of records in the set. However, you then have the problem of moving back to the start: you must have the recordset opened in a particular mode (which I forgot, from the top of my head) to be able to arbitrarily move the cursor pointer back and forward.The usual way of iterating through a cursor is to use a
while
loop, checking for the cursor's end of file: