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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

error checking in ASP 1

Status
Not open for further replies.

rkfox

Programmer
Feb 15, 2002
26
0
0
US
I am writing an ASP application using ADO (naturally) for DB access with an ACCESS database.

I am somewhat confused about error checking and the various ASP options -

When I want to see if an Insert or Update db access worked Which error object should I use ?
The ERR one i.e. err.number
The error collection of the Connection object
or the ASPError object

If I use the Connection or ASPError, how does that work in conjunction with regular VBScript error checking using the ERR object?

Also and more specifically, I also want to check for specific ODBC errors, ie. duplicate record key on an insert - anybody have any samole code as to which error numbers to check for? Or perhaps a better way to do this?

Thanks for your help
 
I would recommend just using the plain old err object properties to check IF there was and error, and what the error description contains if there is.

Like so:
================================================
on error resume next

'do your connection string here...

if err <> 0 then 'The connection line returned an error, handle it..

if instr(err.description) = &quot;File Locked&quot; then...
if instr(err.description) = &quot;Not Opened&quot; then...
if instr(err.description) = &quot;Unable to connect&quot; then...
err.clear 'Clears the error and allows the script to proceed
end if
================================================

Be aware that this resume next approach will puke if more than one line of code between it and the error handler contains or generates an error. Another option you may want to consider is the on error goto command, but if you're just wanting to check the connection line for errors, this should sufice.

Hope this helps
AT
 
Thanks I will give this a try. Do you know if all ADO errors show up in the ERR object?


Thanks
 
As far as I know, the err object is a catch ALL. I've never had any problems with catching ADO errors with it.

There's probably a better way, but this one works for me ;)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top