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

Trapping 0x80004005 error

Status
Not open for further replies.

avivit

Technical User
Jul 5, 2000
456
IL
Hi,

I am trying to trap an error, so that the user will not see it, and that the next line will be excetuted (redirection).
I created on purpose "0x80004005" error, and it is not trapped, but it is shown on whole page for all to see, and does not continue from there. Why is my traaping ignored?

I use no sub/functions. All as main data.

The error refers to trying to insert a new record to MS-ACCESS db containing an existing ID, when ID IS teh key field (thus unique, as should be).

The error:"Microsoft JET Database Engine (0x80004005)
The changes you requested to the table were not successful because they would create duplicate values in the index, primary key, or relationship. Change the data in the field or fields that contain duplicate data, remove the index, or redefine the index to permit duplicate entries and try again."

How can I trap the error, and my is my trapping ignored?

---------------------------
CODE:
---------------------------

On error resume next
'Opening db+recordset...
'Exceuting sql statement (Insert)
'error handling:
IF objDB.errors.count>0 then
response.write "Database Errors"
else
response.write("great")
end if

If err.number>0 then
response.write "VBScript Errors"
'Closing recordset and db and setting to nothing
Response.Redirect (mySite)
--------------------------------------------
--------------------------------------------
Not trapped, I get the above default error, and the redirection does not take place.

Helpppppp

Thanks
 
you can't write to the screen and then redirect as one problem above. try server.transfer for that event.



___________________________________________________________________
onpnt2.gif

The answer to your ??'s may be closer then you think.
Check out Tek-Tips knowledge bank by clicking the FAQ link at the top of the page
 
Even when I delete the redirect line I get the same result.
 
I checked and it jas nothing to do with the redirection.
My problem that the on error statement was not in place.

Now a new problem:

When getting the default error, the line in which the error ocoours in code is mentioned , but when using the objDB.errors collection to trap the error , I didn't find how to get the line number too. Possible?

I see I can get follwing data:

objDB.errors(counter).number
objDB.errors(counter).description

How about the line number the "caused" the probelm?

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top