问题描述
美好的一天,我想问一下关于的错误在下面继续下一个
Good day all, I would like to ask a thing about on error resume next
让我们假设我们有一个循环来浏览记录集,如:
let's assume we have a loop to navigate through a recordset like:
Do while not rs.EOF
query = "UPDATE ...."
conn.execute(query)
rs.movenext
loop
我想确保更新
正在进行,我想检查是否有一些问题,所以我把调试功能放在代码如下:
i would like to be sure the UPDATE
is going good, and i would like to check if there is some problems, so I have put a debugging features in the code like:
Do while not rs.EOF
query = "UPDATE ...."
on error resume next
conn.execute(query)
If Err.Number <> 0 Then
Response.write(Err.Number)
response.write("<br>")
response.write(Err.description)
response.write("<br>")
response.write(query)
response.write("<br><br>")
end if
on error goto 0
rs.movenext
loop
问题是:在循环中,如果遇到错误,下一个循环将会出现错误(因此再次触发错误块)?或错误goto 0
将清除Err对象?
,换句话说,它是否可以作为错误处理?
the question is : during a loop, if it encounters an error, the next cycle will the error be there (and so triggers again the error block) ? or on error goto 0
will clear the Err object?in other words, will it works as a error handling?
推荐答案
VBScript重置 goto 0
:
VBScript resets the error on goto 0
:
on error resume next
i = 1 / 0
WScript.echo( err.number ) '' prints 11 (div by 0)
on error goto 0
WScript.echo( err.number ) '' prints 0 (no error)
还有显式的 err.clear()
。
这篇关于使用“on error resume next”在经典的ASP中,以及如何处理错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!