cnn.execute "Update 人员信息库 set 序号=序号-1 where 序号>2" 用你的方法的话我想应该是UPDATE的时候把指针又移到了首记录你把UPDATE放到LOOP后面就可以了试试看吧 直接用UPDATE 表名 SET 字段= WHERE 是最好的方法
把Update语句换到Do循环之外,试试, 不需要更改一条记录就更新一次, 可以最后才更新么。
同意楼上不过原语句也可以用,在循环前加句 rst.movefirst看看
update ...set where 这我知道。 因为以前在Rdo中我的程序都是这样写的,没有问题update ... set .. where 只能更新有规律数据,我的程序中有很多下面的程序 rst1.source="select * from table1" rst1.open do while not rs1.eof rst2.source="select * from table2 where filed1=rst1!fieldx" rst2.open if rst2!fieldx='xxx' then rst2的某个字段更改 rst2.update end if rs1.movenext loop 所以我只想知道出先这个问题时则么回事
我想是因为你在“select * from 人员信息库 where 序号>2”中没有指定顺序,用“select * from 人员信息库 where 序号>2 order by 序号 asc”试试看! 另外,将rst.update放在循环外面。rst.source="select * from 人员信息库 where 序号>2 order by 序号 asc" rst.open do while not rst.eof rst!序号=rst!序号-1 rst.movenext loop rst.update 请你试完以后告诉我结果如何!
用你的方法的话我想应该是UPDATE的时候把指针又移到了首记录你把UPDATE放到LOOP后面就可以了试试看吧 直接用UPDATE 表名 SET 字段= WHERE 是最好的方法
不需要更改一条记录就更新一次,
可以最后才更新么。
rst.movefirst看看
因为以前在Rdo中我的程序都是这样写的,没有问题update ... set .. where 只能更新有规律数据,我的程序中有很多下面的程序
rst1.source="select * from table1"
rst1.open
do while not rs1.eof
rst2.source="select * from table2 where filed1=rst1!fieldx"
rst2.open
if rst2!fieldx='xxx' then
rst2的某个字段更改
rst2.update
end if
rs1.movenext
loop
所以我只想知道出先这个问题时则么回事
rst.open
do while not rst.eof
rst!序号=rst!序号-1
rst.movenext
loop
rst.update
请你试完以后告诉我结果如何!
Montaque==Digitalboy==Houyongfeng==Monkey
还是不行。死循环。
eof 没有等于True
do while "序号">0
建议你用debug.print查看一下每次循环减一的是那些记录,和数据库对比一下。
是不是不停的把同一个序号一直减到2了?