开发者

How do I distinguish ADO Database Errors in VB6

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 er开发者_StackOverflow社区ror numbers used here?


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


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜