不用 EOF 以加快记录循环(vb)转贴

- 中国WEB开发者网络 (http://www.webasp.net)
-- 技术教程 (http://www.webasp.net/article/)
--- 不用 EOF 以加快记录循环(vb)转贴 (http://www.webasp.net/article/4/3063.htm)
-- 作者:未知
-- 发布日期: 2003-07-11
通常我们使用以下的代码进行记录循环:

Do while not records.eof
combo1.additem records![Full Name]
records.movenext
loop

结果是每个循环中数据库都要进行一次数据结束测试。在大量的记录的情况下, 浪费的时间相当大。 而使用以下的代码, 可以提高近 1/3 的速度:

records.movelast
intRecCount=records.RecordCount
records.movefirst

for intCounter=1 to intRecCount
combo1.additem records![Full Name]
records.movenext
next intCounter

webasp.net