如何区分VB6中的ADO数据库错误

发布于 2024-10-07 14:11:22 字数 293 浏览 0 评论 0原文

我正在使用 ADO 从 VB6 应用程序读取和写入数据库。当然,数据库访问可能会返回错误。我目前通过从此处借用的方法显示错误消息 http://www.devx.com/ Tips/Tip/13483 但我希望在我的代码中根据错误是否违反索引约束、违反列约束、触发器强制错误等采取不同的行动。

我查看集合中第一个错误的 .Number 部分是否正确?还是最后一个?

有谁知道我可以在哪里找到此处使用的错误号列表?

I'm using ADO to read and write a database from a VB6 application. Naturally, the database access may return errors. I am currently displaying an error message by a method borrowed from here http://www.devx.com/tips/Tip/13483 but I would like, in my code, to act differently according to whether the error is an index constraint violation, a column constraint violation, trigger forced an error and so forth.

Would I be right in looking in the .Number part of the first error in the collection? Or the last?

And does anyone know where I might find a list of the error numbers used here?

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

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

发布评论

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

评论(3

命硬 2024-10-14 14:11:22

ErrorValueEnum 指定 ADO 运行的类型- 带有 ADO 错误代码列表的时间错误。

ErrorValueEnum specifies the type of ADO run-time error with a list of ADO error codes.

尽揽少女心 2024-10-14 14:11:22

不,Err.Number 仅包含从 ADO 角度来看的错误。数据库内部错误是特定于数据库的。例如,在 Oracle 中,您关心的几乎所有错误都与模式 ORA-(\d{5}) 匹配,您可以从 Err.Description 中提取该值以找出确切的错误代码。

No, Err.Number will only contain the error from the ADO standpoint. Database internal errors are database specific. For example, in Oracle nearly all errors that you'd care about match the pattern ORA-(\d{5}) and you could pull that value from Err.Description to find out the exact error code.

香草可樂 2024-10-14 14:11:22

对返回的数据结构进行更仔细的研究表明它有一个成员 .SQLState,其中包含我正在寻找的内容。向 Dan 和 systempuntoout 道歉,因为之前没有注意到这一点。

More careful study of the data structure returned reveals it has a member .SQLState, which contains what I am looking for. Apologies to Dan and systempuntoout for not noticing this before.

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