经典的 asp connection.errors 集合实际上是如何工作的?

发布于 2024-12-24 19:20:43 字数 562 浏览 0 评论 0原文

我试图确认实际的 ADODB.Connection.Errors 集合实际上应该如何工作。

我目前的解释是,该连接将保留在该连接上执行的所有过程的所有错误。

所以我应该可以说

on error resume next 

... code goes here ... 2 or more command objects execute procedures against the database on the same connection

if con.Errors <> 0 then 

  loop through all the Errors objects (1 for each procedure that would've been executed on the connection)

end if 

但是我已经实现了该基本结构并且我只得到了一个错误描述?所以我正在寻找某人来确认情况确实如此。 Errors 集合是否包含多个过程的多个错误?或者一个过程是否发生多个错误?

我似乎找不到任何文档可以准确说明这种情况下会发生什么。

谢谢,

I am trying to confirm how the actual ADODB.Connection.Errors collection should actually work.

My interpretation at the moment is that the connection will hold all the errors for the all the procedures that have been executed on that connection.

So I should be able to say

on error resume next 

... code goes here ... 2 or more command objects execute procedures against the database on the same connection

if con.Errors <> 0 then 

  loop through all the Errors objects (1 for each procedure that would've been executed on the connection)

end if 

However I have implemented that basic structure and I only get the one error description? So I am looking for someone to confirm that is the case. Does the Errors collection hold more than one error for more than one procedure? Or is if multiple errors occurred for one procedure?

I can't seem to find any documentation that would indicate exactly what would happen in this case.

Thanks,

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

小苏打饼 2024-12-31 19:20:43

来自 错误集合 (ADO) - MSDN

任何涉及ADO对象的操作都可以生成一个或多个provider
错误。当每个错误发生时,可以放置一个或多个 Error 对象
在 Connection 对象的 Errors 集合中。 当另一个ADO
操作生成错误,Errors 集合被清除,并且
新的 Error 对象集可以放置在 Errors 集合中

因此,要捕获所有错误,似乎需要在每个可能的错误后检查集合。

from Errors Collection (ADO) - MSDN:

Any operation involving ADO objects can generate one or more provider
errors. As each error occurs, one or more Error objects can be placed
in the Errors collection of the Connection object. When another ADO
operation generates an error, the Errors collection is cleared, and
the new set of Error objects can be placed in the Errors collection
.

So, to catch all errors, seems to be need to check the collection after each possible error.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文