sql1="select * from ems_dbxx"Set rs1=Server.CreateObject("ADODB.RecordSet") rs1.Open sql1,Conn,1,2 if rs1.eof and rs1.bof then response.write"<script>alert('错误!');</script>" else while not(rs1.eof) for i=1 to 12 Conn.Execute("update ems_dbxx set dbxx_lastmonth='"&i&"' where dbxx_m"&i&" is not null") next rs1.movenext wend end if response.Write"<script>alert('时间更新成功!');window.location='dbxx_edit.asp';//</script>"
这段代码是对一张设备检修表操作,获取每台设备的最后一次检修时间,把最后一次检修的月份存入字段“dbxx_lastmonth”。这段代码是在一个网友的帮助呀写的,但是效率太慢,数据少的时候还行,上千台设备的时候就会提示:超过了脚本运行的最长时间。
怎么修改一下能提高运算的效率呢??
<% dim n sql1="select * from ems_dbxx"Set rs1=Server.CreateObject("ADODB.RecordSet") rs1.Open sql1,Conn,1,3 if rs1.eof and rs1.bof then response.write"<script>alert('错误!');</script>" else while not(rs1.eof) n="" for i=1 to 12 if rs1("dbxx_m"&i)<>null then n=i next if n<>"" then rs1("dbxx_lastmonth")=n rs1.update end if rs1.movenext wend end if Rs1.Close:Set Rs1=Nothingresponse.Write"<script>alert('时间更新成功!');window.location='dbxx_edit.asp';</script>"%>