Force error message when database is missing

B

Brian Purcell

Hello all,
I have a FrontPage ASP file writing form data to an Access database on
a different server. Everything works fine. But, if the backend
database is missing for some reason (e.g. server down), and someone
submits the form, they get a confirmation page and everything looks
like it worked fine even though the data was lost. How can I force FP
to return an error message if the database is missing, either when the
user submits the form or, if possible, when the user initially loads
the form?

Thanks very much in advance.

--Brian
 
J

Jim Carlock

Just tossing some ideas your way.

In the ASP section, use On Error Resume Next near the
top after the Response.Buffer lines.

Then check for an error after attempting to make the
connection, after attempting to update...
<%
Option Explicit
Response.Buffer = True
Dim oAdoDB, oAdoRS, sConn, sRS
On Error Resume Next
'...code to establish connection

If Err.Number <> 0 Then
subResponseRedirect "problem.asp"
End If
'...code to open recordset
If Err.Number <> 0 Then
subResponseRedirect "problem.asp"
End If

'...more code to close/destroy data connections, recordsets
'...
Response.Redirect "http://otherserver.com/html/otherpage.asp"
Response.End

Sub subResponseRedirect(sRedirectPage)
Response.Redirect sRedirectPage
Response.End
End Sub
%>

You can also do something like ping the other server, but
that will not tell you if the database connection succeeded.
I don't have the code to demonstrate that, perhaps
someone else can demonstrate it.

Hope that helps.

--
Jim Carlock
Post replies to newsgroup.


"Brian Purcell" commented:
Hello all,
I have a FrontPage ASP file writing form data to an Access database on
a different server. Everything works fine. But, if the backend
database is missing for some reason (e.g. server down), and someone
submits the form, they get a confirmation page and everything looks
like it worked fine even though the data was lost. How can I force FP
to return an error message if the database is missing, either when the
user submits the form or, if possible, when the user initially loads
the form?

Thanks very much in advance.

--Brian
 
B

Brian Purcell

Jim Carlock said:
Just tossing some ideas your way.
[...]

Jim Carlock
Post replies to newsgroup.

Thanks for that reply. I went a different route; I'm posting here for
others to use--

1. Edit the fpdbrgn1.inc file (in the _fpclass folder). Locate this
line near the bottom:
Response.Write "The operation failed. If this continues, please
contact your server administrator.<br>"

Replace that line with these two lines:
Response.Redirect "http://yourweb.yourdomain.com/error.asp"
Response.End

(Be sure you have a page in that location called "error.asp"; you can
put a custom error message on it e.g. "There is an error with this
database-- please try again later or contact technical support... blah
blah")

2. On your confirmation page, do a database lookup near the top of the
page using the same database you just wrote to. You don't have to
display any results on the page, just do a valid query against the
database.

What will happen is this--
The user will submit their form data. The confirmation page will be
returned, but if the database is missing, FP will redirect to the
error.asp page you specified above instead. Otherwise, it will return
the rest of the confirmation page.

You can also do the database query at the top of the form page. That
way, the user will never even be able to fill-out the form if the
database is missing. Just make sure you do another query on the
confirmation page in case something happened to the database between
the time the user loaded the form and the time they submitted it.

--Brian
 
B

Brian Purcell

I said:
1. Edit the fpdbrgn1.inc file (in the _fpclass folder). Locate this
line near the bottom:
Response.Write "The operation failed. If this continues, please
contact your server administrator.<br>"

If you can't find that line your fpbdrgn1.inc file, it means you
haven't created any database results pages in your web yet. Go ahead
and do step 2 on my instructions, then go back and do step 1. You
should now have that line in your fpbdrgn1.inc file.

--Brian
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top