Home All Groups Group Topic Archive Search About

Detect Connection to DB

Author
1 Jul 2009 8:44 AM
Dooza
Hi there,
I have an intranet on our corporate network. The home page has a
recordset that displays manufacturers in a drop down list. The recordset
gets it data from a database on our co-located webserver.

Very occasionally our internet connection will drop, and during this
time our intranet home page becomes inaccessible due to not being able
to connect to the database server.

What is the best way to deal with this scenario? I would like the page
to carry on being functional, but without the data from the database.
Ideally I would display a message saying the database server is unavailable.

Any ideas?

Cheers,

Steve

Author
1 Jul 2009 11:01 AM
Bob Barrows
Dooza wrote:
> Hi there,
> I have an intranet on our corporate network. The home page has a
> recordset that displays manufacturers in a drop down list. The
> recordset gets it data from a database on our co-located webserver.
>
> Very occasionally our internet connection will drop, and during this
> time our intranet home page becomes inaccessible due to not being able
> to connect to the database server.
>
> What is the best way to deal with this scenario? I would like the page
> to carry on being functional, but without the data from the database.
> Ideally I would display a message saying the database server is
> unavailable.
Without seeing your code, all I can offer is this air code to illustrate
error-handling:

set cn=createobject("adodb.connection")
on error resume next 'turn on error handling
cn.open connectionstring
if err <> 0 then
    response.write "could not connect to database"
    response.end
end if
on error goto 0 'turn off error handling

It is best practice to leave error-handling off except for those statements
that "need" it so as not to mask any other errors that occur in your code.

--
Microsoft MVP - ASP/ASP.NET - 2004-2007
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Are all your drivers up to date? click for free checkup

Author
1 Jul 2009 11:29 AM
Dooza
Bob Barrows wrote:
Show quoteHide quote
> Dooza wrote:
>> Hi there,
>> I have an intranet on our corporate network. The home page has a
>> recordset that displays manufacturers in a drop down list. The
>> recordset gets it data from a database on our co-located webserver.
>>
>> Very occasionally our internet connection will drop, and during this
>> time our intranet home page becomes inaccessible due to not being able
>> to connect to the database server.
>>
>> What is the best way to deal with this scenario? I would like the page
>> to carry on being functional, but without the data from the database.
>> Ideally I would display a message saying the database server is
>> unavailable.
> Without seeing your code, all I can offer is this air code to illustrate
> error-handling:
>
> set cn=createobject("adodb.connection")
> on error resume next 'turn on error handling
> cn.open connectionstring
> if err <> 0 then
>     response.write "could not connect to database"
>     response.end
> end if
> on error goto 0 'turn off error handling
>
> It is best practice to leave error-handling off except for those statements
> that "need" it so as not to mask any other errors that occur in your code.

Hi Bob,
Thank you, this will do the job nicely.

Cheers,

Steve

Bookmark and Share