Click to See Complete Forum and Search --> : Custom Error page


stacekz
12-30-2005, 08:03 AM
I'd like to know if it's possible to display custom error pages when this error occurs:

Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

[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.

I know that IIS can handle and display custom error messages but is there a way to handle this event client side and redirect the user to another page?

Thanks in advance,

Stacey

ASP JavaScript MX2004

Ubik
12-30-2005, 09:46 AM
You need to find out what Err.Number that particular error is, then:



If Err.Number = intTheErrorNumber Then
err.clear
Response.redirect("anotherpage.asp")
end if


You may already know this but: you have to send redirects beofre any headers, so this should be at the top of your asp page, and no 'response.flush' can appear before it in the code.

chrismartz
12-30-2005, 11:25 AM
Why do you want to redirect on error anyway?

russell
12-30-2005, 09:12 PM
there is no way to handle a server error on the client side. server errors must be handled server side. that said, ubik's answer is a decent way to do it.

or see This Thread (http://www.webdeveloper.com/forum/showthread.php?t=53128)

russell_g_1
12-31-2005, 06:13 AM
i almost always use this function when i access a db. if you did something like this it would mean you only have to put your error handling code in one place.

(i usually make the function send me an email when it errors)

function runsql(sql, byref rs)

runsql = true
dim connstr

connstr = "Driver={SQL Server};server=(local);database=test1;uid=sa;pwd=qwertyuiop;"

on error resume next

set rs = createobject("adodb.recordset")
rs.open sql, connstr, 1, 3
if err then
runsql = false
set rs = nothing
end if

end function