for i=0 to rs.recount-1 if .. then 执行动作 exit for end if rs.movenext next
可以这样: with rs .findfirst "fieldname=" & fieldvalue if not .nomatch then ...找到了,处理 end if end with while not rs.eof if .. then 执行动作 end if rs.movenext wend
if rs.states<>adstateclosed then rs.close end ifrs.commandtext="select * from ... where ... order by ..." rs.open if rs.recordcount<>0 then for i=1 to rs.recordcount do if ... then ... exit sub end if next i end if
不好意思,我前面把where误写成while了,以后一定注意。 to 各位: 看来sql语句效率是高,那我也很愿意用sql! 谢谢各位,请以后继续帮助!!
ado1.recordsource="select * from 表 while 条件"选出记录,然后再对ado1.recordset(字段)进行操作即可?这样速度会提高吗?
你真的要好好看看SQL语句的书了,
select * from 表 where a = 1 and/or ....
可以这样嘛。。
怎么说呢,你的哪一条方法里面有where?
我只看到一个while.
使用这种方法显然比你的那个循环的方法效率要高。
由于数据库里面的数据排列是已经排序好的。
所以在搜索的时候就可以使用折半查找等较好的算法,你的那种从头循环到尾的搜索
方法实在不是个访问数据库的好方法:P
if .. then
执行动作
exit for
end if
rs.movenext
next
with rs
.findfirst "fieldname=" & fieldvalue
if not .nomatch then
...找到了,处理
end if
end with
while not rs.eof
if .. then
执行动作
end if
rs.movenext
wend
rs.close
end ifrs.commandtext="select * from ... where ... order by ..."
rs.open
if rs.recordcount<>0 then
for i=1 to rs.recordcount do
if ... then
...
exit sub
end if
next i
end if
to 各位:
看来sql语句效率是高,那我也很愿意用sql!
谢谢各位,请以后继续帮助!!