Submit Your Article Webforumz RegistrationAnnouncements Contact Webforumz StaffContact
Home Resources Blogs Meet the Team Contact Register
 

Go Back   WebForumz.com > The Code > Classic ASP

Closed Thread
 
LinkBack Thread Tools
Old August 13th, 2004, 01:00 AM   #1
Most Reputable Member
 

Join Date: Feb 2004
Location: Borneo
Age: 28
Posts: 1,628
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Rep Altering Power: 0 Monie is a jewel in the rough Monie is a jewel in the rough Monie is a jewel in the rough Monie is a jewel in the rough
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????
Monie is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Old August 13th, 2004, 04:16 AM   #2
WebForumz Admin Badge
 

Join Date: Jul 2003
Posts: 1,848
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 118 Webforumz Staff is on a distinguished road
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)
Webforumz Staff is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Old August 13th, 2004, 04:25 AM   #3
Rob
Elite Veteran
SuperMember
 
Rob's Avatar
 

Join Date: Jul 2003
Location: Southern UK
Age: 35
Posts: 3,126
Blog Entries: 7
Thanks: 28
Thanked 22 Times in 19 Posts
Rep Altering Power: 0 Rob is a jewel in the rough Rob is a jewel in the rough Rob is a jewel in the rough
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 - Webforumz Founder
Web Designer Support Network || Personal Project: Sanctuary for Student Midwives
Rob is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Old August 13th, 2004, 04:37 AM   #4
WebForumz Admin Badge
 

Join Date: Jul 2003
Posts: 1,848
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 118 Webforumz Staff is on a distinguished road
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.
Webforumz Staff is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Old August 13th, 2004, 04:43 AM   #5
Highly Reputable Member
 

Join Date: Jul 2003
Location: Ipswich, UK
Posts: 686
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 Smokie will become famous soon enough
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:
<% 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:
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.
Smokie is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Old August 16th, 2004, 10:37 PM   #6
Most Reputable Member
 

Join Date: Feb 2004
Location: Borneo
Age: 28
Posts: 1,628
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Rep Altering Power: 0 Monie is a jewel in the rough Monie is a jewel in the rough Monie is a jewel in the rough Monie is a jewel in the rough
thanx smokie, that helps me alot
Monie is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Old August 17th, 2004, 04:07 AM   #7
WebForumz Admin Badge
 

Join Date: Jul 2003
Posts: 1,848
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 118 Webforumz Staff is on a distinguished road
<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]
Webforumz Staff is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Closed Thread

Bookmarks

Tags
asp , friendly , error


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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 January 16th, 2008 04:16 PM
Pro design and CMS that is SE friendly paulhudson Your Design and Layout 11 June 18th, 2007 07:29 PM
friendly suggestion from the new guy... bg38 WebForumz Suggestions 12 September 20th, 2006 08:12 AM


Search Engine Optimization by vBSEO 3.2.0 RC8