how to do an asp friendly error?

This is a discussion on "how to do an asp friendly error?" within the Classic ASP section. This forum, and the thread "how to do an asp friendly error? are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > Classic ASP

Notices


Closed Thread
 
LinkBack Thread Tools
  #1 (permalink)  
Old Aug 13th, 2004, 05:00
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,608
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Send a message via Yahoo to Monie
how to do an asp friendly error?

well...in my database(ACCESS), i have made two field to be a "PRIMARY KEY".
When i do the testing by entering the same value to this field in my ASP form, this is the IE error page saying something about the PRIMARY KEY!

----------------------------------------------------------------------
Technical Information (for support personnel)
Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC Microsoft Access Driver] 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.
/admin/insertClassroomInfo.asp, line 90


Browser Type:
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)

Page:
POST 55 bytes to /admin/insertClassroomInfo.asp
---------------------------------------------------------------------

but instead of the IE error reporting them, i want my own Error Reporting (errorReporting.asp) page to be displayed! with my own message writen inside it!

HOW TO DO THIS SO CALL AN ASP USER FRIENDLY ERROR PAGE????
Last Blog Entry: ASP Programming Tips and Technique (Oct 26th, 2007)

  #2 (permalink)  
Old Aug 13th, 2004, 08:16
Most Reputable Member
Join Date: Jul 2003
Posts: 1,856
Thanks: 0
Thanked 0 Times in 0 Posts
Maybe we could do an article on this guys? (Sorry monie I don't know the answer myself, but I'm sure Rob, Catalyst and Smokie do...lol)
  #3 (permalink)  
Old Aug 13th, 2004, 08:25
Rob's Avatar
Rob Rob is offline
Head Admin & CEO

SuperMember
Join Date: Jul 2003
Location: at my desk
Age: 34
Posts: 2,952
Blog Entries: 7
Thanks: 7
Thanked 4 Times in 4 Posts
Send a message via MSN to Rob Send a message via Skype™ to Rob
Actually.... all this needs is a call to the database FIRST.... Select records with the matching key you want to insert. If there are any records returned, then you know that inserting a record would fail and raise an error.... you can handle it from there.
__________________
Rob - SEO Specialist
Owner & Founder of Webforumz.com

I am currently unavailable for private work
  #4 (permalink)  
Old Aug 13th, 2004, 08:37
Most Reputable Member
Join Date: Jul 2003
Posts: 1,856
Thanks: 0
Thanked 0 Times in 0 Posts
Like Rob says there's better ways to do it, but if you do want the error thing then read up on using:
On Error Resume Next

You can then check the ERR object to see if any errors have happened and write out a message or redirect to a page based on the error type/number.

Google it for samples, etc.
  #5 (permalink)  
Old Aug 13th, 2004, 08:43
Highly Reputable Member
Join Date: Jul 2003
Location: Ipswich, UK
Posts: 690
Thanks: 0
Thanked 0 Times in 0 Posts
Well if you have access to the server and IIS, you can choose to not display errors to the user, or you can choose your own ASP page which runs when different errors occurs, or you can do this.

Insert this at the top of your ASP page:

Code: Select all
<% On Error Resume Next %>
This will tell ASP to just skip over any errors, instead of halting execution and printing out a nasty error message.

Then after any ADO call that accesses the database, put the following lines:

Code: Select all
If Err.number <> 0 then
  Response.Redirect "errorReporting.asp"
End If
You will want to put this after all ADO calls that communicate directly with the database. This includes ConnectionObject.Open, ConnectionObject.Execute, and RecordsetObject.Open.
  #6 (permalink)  
Old Aug 17th, 2004, 02:37
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,608
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Send a message via Yahoo to Monie
thanx smokie, that helps me alot
Last Blog Entry: ASP Programming Tips and Technique (Oct 26th, 2007)
  #7 (permalink)  
Old Aug 17th, 2004, 08:07
Most Reputable Member
Join Date: Jul 2003
Posts: 1,856
Thanks: 0
Thanked 0 Times in 0 Posts
<blockquote id="quote" class="ffs">quote:<hr height="1" noshade="noshade" id="quote" />Originally posted by Sirkent
Maybe we could do an article on this guys? (Sorry monie I don't know the answer myself, but I'm sure Rob, Catalyst and Smokie do...lol)<hr height="1" noshade="noshade" id="quote" /></blockquote id="quote">

I'm more impressed that Rob, Catalyst and Smokie actually answered in the order I said their names [:P]
Closed Thread

Tags
asp, friendly, error

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Are JavaScripts SEO Friendly? maneetpuri Search Engine Optimization (SEO) 4 Jan 16th, 2008 20:16
Pro design and CMS that is SE friendly paulhudson Starting Out 11 Jun 18th, 2007 23:29
friendly suggestion from the new guy... bg38 Webforumz Suggestions and Feedback 12 Sep 20th, 2006 12:12


All times are GMT. The time now is 20:55.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43