|
it
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Detect Connection to DBHi 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 Dooza wrote:
> Hi there, Without seeing your code, all I can offer is this air code to illustrate > 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. 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" Bob Barrows wrote:
Show quoteHide quote > Dooza wrote: Hi Bob,>> 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. Thank you, this will do the job nicely. Cheers, Steve
Other interesting topics
Large row count from stored procedure
Urgent: getting recordcount after running Stored Procedure LEFT JOIN problem How can I type in the combo box <select> ? How to change all relative paths in a website??? Classic ASP, <SELECT> postback, Browser Navigation Microsoft OLE DB Provider for ODBC Drivers error '80004005' Script from variables Problem with Instr to find a space Cannot use parentheses when calling a Sub |
|||||||||||||||||||||||