HTTP Error code of SQL server down

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • prinsipe
    New Member
    • Jun 2007
    • 14

    HTTP Error code of SQL server down

    what will be the http error code (ex. 404, 500) produced when an sql server is down due to maintenance works? thanks in advance =)
  • radcaesar
    Recognized Expert Contributor
    • Sep 2006
    • 759

    #2
    HTTP doesn't know about your database. You have to chack this using SQLDMO.

    Comment

    • prinsipe
      New Member
      • Jun 2007
      • 14

      #3
      thanks for the reply but what i meant was...if I try to access a website that has a sql server under maintenance (assuming the site has no custom error page) what will be the error displayed by the site.

      Comment

      • Shashi Sadasivan
        Recognized Expert Top Contributor
        • Aug 2007
        • 1435

        #4
        in that case it would act as if your application was connecting to a non existant database.

        And will throw an exception.

        If that exception is not caught, it will show a very non-informational data to the "common" user.

        So the catch here is to catch the exception

        Comment

        • prinsipe
          New Member
          • Jun 2007
          • 14

          #5
          what exception will it throw? i am creating a custom error page specifically for sql server that is under maintenance. right now, im using error code 500 internal server error. is this correct? or is there any more appropriate error code to use?
          thank you very much...

          Comment

          • Shashi Sadasivan
            Recognized Expert Top Contributor
            • Aug 2007
            • 1435

            #6
            I think that would depends upon how much of the server is down.
            If the entire server is down then the instance of the server will not be found,
            If only the database is down then the initial catalogue will fail.

            not sure of the exact errors though.

            you could try that by playing with your connection string.
            Edit: I tried that....on both occasions it gives SqlException. However with different messages (but if you do recieve this exception, it should probabl be because of this reason, it will also throw this exception if there is a non existing stored procedure / funtion which has been called)

            cheers
            Last edited by Shashi Sadasivan; Oct 23 '07, 07:00 AM. Reason: tried the combinations, another reason for exception

            Comment

            • radcaesar
              Recognized Expert Contributor
              • Sep 2006
              • 759

              #7
              Else Check for the Status of the SQL Server Service status using some custom code.

              :)

              Comment

              • Plater
                Recognized Expert Expert
                • Apr 2007
                • 7872

                #8
                It will probably throw an SqlException (or an analouge like OdbException depening on your database type)

                Comment

                • JamieHowarth0
                  Recognized Expert Contributor
                  • May 2007
                  • 537

                  #9
                  Hi there,

                  I'm not a .NET pro but you could use Try... Catch to attempt retrieval of data, then if the database server is down for whatever reason, you use code in the Catch to handle the error and show something nice and user-friendly.

                  Best regards,

                  medicineworker

                  Comment

                  Working...