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

ASP page won't display errors

Status
Not open for further replies.

SuaveRick

Programmer
Apr 12, 2004
142
CA
Hi there,
I have an ASP page here that I'm using to insert records into an Access database. I want to do some error handling cause I know there are going to be users who will try and enter duplicate records. When access returns the error saying that a record already exists I'd like to catch that and show the user in a nicer way than the standard IE error page. I am trying to enter duplicate data and have the code below but it doesn't show me anything beside the standard error page, what am I doing wrong? I've created the error

I have this code:
Dim objErr
Set objErr = Server.CreateObject("ADODB.Error")
'all the standard stuff here

strSql = "insert into facilitator".......... blah blah

rs.open strSql, adoCon 'execute the command
for each objErr in adoCon
response.write(objErr.Description)
next

I get nothing but that standard error page, any help?
 
SuaveRick,

I don't see 'On Error Resume Next' anywhere here. Your code craps out before it hits your error handler......

Toga
 
I tried what you said but it still get that default error page. Is the error of trying to add a duplicate record not one that creates an object?

Here is my exact code:

rs.open strFacSql, adoCon
on error resume next
for each objErr in adoCon
response.write(objErr.Description)
next

thanks
 
Try just changing the order like this:


on error resume next

rs.open strFacSql, adoCon

for each objErr in adoCon
response.write(objErr.Description)
next

if err.number <> 0 then
'Secondary catch for erros not in connection object
response.write "Error opening ADO recordset."
end if

 
That's what I needed to do. Now I can access err.number .description, whatever and handle the error my way.

Thank you very much!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top