Brian Hooper
Brian Hooper

Reputation: 22054

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 error numbers used here?

Upvotes: 0

Views: 937

Answers (3)

Brian Hooper
Brian Hooper

Reputation: 22054

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.

Upvotes: 0

Dan
Dan

Reputation: 11069

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.

Upvotes: 1

systempuntoout
systempuntoout

Reputation: 74094

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

Upvotes: 2

Related Questions