Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reporting ADO Errors 1

Status
Not open for further replies.

campbere

Technical User
Oct 10, 2000
146
US
I am trying to report errors that occur with the ADO connection. Currently I have the following code:

What I would like is more specific errors. For instance I am using an Oracle database and if it is an Oracle error I would like for it to display that. Another example is this error check is done after the user enters their id and password if it is just a simple case of wrong user id or password I would like for the error message to include this.

Does anyone have information on how to do this? How to report Oracle errors through ADO?

Dim er As ADODB.Error
Dim errmsg As String

For Each er In objConn.Errors
errmsg = errmsg & &quot;Description: &quot; & er.Description & &quot;<br>&quot;
errmsg = errmsg & &quot; Number: &quot; & &quot; &quot; & er.Number & &quot;<br>&quot;
errmsg = errmsg & &quot; Source: &quot; & &quot; &quot; & er.Source & &quot;<br>&quot;
errmsg = errmsg & &quot; SQL State: &quot; & &quot; &quot; & er.SQLState & &quot;<br>&quot;
errmsg = errmsg & &quot; Native Error: &quot; & &quot; &quot; & er.NativeError & &quot;<br>&quot;
Next er
 
Yeah you can,

When when ado error occurs it generates a native error (as you know)

Now on your code above you can check the native error code and use a select case to send a unique (well almost) message.

Select Case er.NativeError
case 2291 'Parent Key Not Found
case #### 'Duplicate ...
...
end select

This is a tedious process by way of having to try and generate every possible error while in development.

But you can probably get a full list of errors from Oracle. (OTN maybe)

You can check out thread222-131751 for more help-ish

Ciao >:):O>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top