MSg in ASP page when the database is down?

Posted on 2004-11-02
Last Modified: 2010-04-17
Hi all

   I have a page which displays details fetched from my oracle database which is in another server and connected thru a DSN. But sometimes if my datasbe server is phisically down, i am getting an erro msg " Microsoft oledb database...". I need to display a proper error msg when this is happing. How do I do thru ASP coding. Pleas ehelp me.
Thansk in advance.
Question by:rgvn
    1 Comment
    LVL 2

    Accepted Solution

    Turn on error handling, and check the value of Err.Number. If an error occurs then write a message using Response.Write.
    An example using ADO:

    on error resume next
    '<-- Insert your own database access code here.
    '      set oRS = Server.CreateObject("ADODB.Recordset")
    '      oRS.Open storedProc, connectionString
    If Err.Number <> 0 then
        Response.Write "The server cannot be reached. Please try again later."
    End If

    Instead of writing the message directly on the data access page, and ending the response, you could send your client to a separate page, using Response.Redirect "pageURL" or Server.Transfer "pageURL". That page could be a simple html page that you reference for this sort of error throughout your application.


    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Join & Write a Comment

    This is an explanation of a simple data model to help parse a JSON feed
    Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
    In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now