How to check if SQL Server is running via asp.net

Discussion in 'ASP .Net' started by wwwmike@gmx.ch, Sep 2, 2006.

  1. Guest

    Problem: When my provider shuts down the SQL Server IIS receives a few
    error messages and then switches the site to 'SERVICE UNAVAILABLE'.

    Before IIS kills itself it is friendly enough to send me an error
    message.

    ****ERROR MESSAGE 1******
    System.Data.SqlClient.SqlException: An error has occurred while
    establishing a connection to the server. When connecting to SQL Server
    2005, this failure may be caused by the fact that under the default
    settings SQL Server does not allow remote connections.


    This error message happens when the server is offline and my ASP.NET 2
    code tries to open a connection

    .....
    myConnection.Open()
    .....

    The last error message I receive is

    *****ERROR MESSAGE 2*****
    System.InvalidOperationException: Timeout expired. The timeout period
    elapsed prior to obtaining a connection from the pool. This may have
    occurred because all pooled connections were in use and max pool size
    was reached


    I am not sure if the ERROR MESSAGE 2 really is about the connection
    pool, since the sql server is already down. But this might trigger IIS
    to set my service unavailable.



    What can I do in my asp.net code to detectd if a SQL server is online?
     
    , Sep 2, 2006
    #1
    1. Advertising

  2. There are two specfic exceptions are thrown when you try to connect to the
    back end i.e this line of code:

    conn.Open()

    1. InvalidOperationException

    2. SqlException

    What can I do in my asp.net code to detectd if a SQL server is online?

    to resolve it ....catch SqlException error

    If the Number property contains the value 18487 or 18488, this indicates
    that the specified password has expired or must be reset. Check for Number
    property to identify the cause of the issue..

    Raj
    "" wrote:

    > Problem: When my provider shuts down the SQL Server IIS receives a few
    > error messages and then switches the site to 'SERVICE UNAVAILABLE'.
    >
    > Before IIS kills itself it is friendly enough to send me an error
    > message.
    >
    > ****ERROR MESSAGE 1******
    > System.Data.SqlClient.SqlException: An error has occurred while
    > establishing a connection to the server. When connecting to SQL Server
    > 2005, this failure may be caused by the fact that under the default
    > settings SQL Server does not allow remote connections.
    >
    >
    > This error message happens when the server is offline and my ASP.NET 2
    > code tries to open a connection
    >
    > .....
    > myConnection.Open()
    > .....
    >
    > The last error message I receive is
    >
    > *****ERROR MESSAGE 2*****
    > System.InvalidOperationException: Timeout expired. The timeout period
    > elapsed prior to obtaining a connection from the pool. This may have
    > occurred because all pooled connections were in use and max pool size
    > was reached
    >
    >
    > I am not sure if the ERROR MESSAGE 2 really is about the connection
    > pool, since the sql server is already down. But this might trigger IIS
    > to set my service unavailable.
    >
    >
    >
    > What can I do in my asp.net code to detectd if a SQL server is online?
    >
    >
     
    =?Utf-8?B?UmFq?=, Sep 2, 2006
    #2
    1. Advertising

  3. re:
    > System.Data.SqlClient.SqlException: An error has occurred while
    > establishing a connection to the server. When connecting to SQL Server
    > 2005, this failure may be caused by the fact that under the default
    > settings SQL Server does not allow remote connections.


    Networking protocols are disabled by default in SQL Server Express.

    If someone simply installs Express and chooses all the defaults, SQL Server Express will only
    be able to have connections originating on the local machine where SQL Server is installed.

    You need to expressly enable networking protocols.

    To fix that, follow the instructions outlined at :
    http://support.microsoft.com/default.aspx?scid=kb;EN-US;914277
    or
    http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=271795&SiteID=1



    Juan T. Llibre, asp.net MVP
    aspnetfaq.com : http://www.aspnetfaq.com/
    asp.net faq : http://asp.net.do/faq/
    foros de asp.net, en espaƱol : http://asp.net.do/foros/
    ===================================
    <> wrote in message news:...
    > Problem: When my provider shuts down the SQL Server IIS receives a few
    > error messages and then switches the site to 'SERVICE UNAVAILABLE'.
    >
    > Before IIS kills itself it is friendly enough to send me an error
    > message.
    >
    > ****ERROR MESSAGE 1******
    > System.Data.SqlClient.SqlException: An error has occurred while
    > establishing a connection to the server. When connecting to SQL Server
    > 2005, this failure may be caused by the fact that under the default
    > settings SQL Server does not allow remote connections.
    >
    >
    > This error message happens when the server is offline and my ASP.NET 2
    > code tries to open a connection
    >
    > ....
    > myConnection.Open()
    > ....
    >
    > The last error message I receive is
    >
    > *****ERROR MESSAGE 2*****
    > System.InvalidOperationException: Timeout expired. The timeout period
    > elapsed prior to obtaining a connection from the pool. This may have
    > occurred because all pooled connections were in use and max pool size
    > was reached
    >
    >
    > I am not sure if the ERROR MESSAGE 2 really is about the connection
    > pool, since the sql server is already down. But this might trigger IIS
    > to set my service unavailable.
    >
    >
    >
    > What can I do in my asp.net code to detectd if a SQL server is online?
    >
     
    Juan T. Llibre, Sep 2, 2006
    #3
  4. Wrap your first SQL call in a try /catch /finally block and output a friendly
    message from within the exception block.
    Peter

    --
    Co-founder, Eggheadcafe.com developer portal:
    http://www.eggheadcafe.com
    UnBlog:
    http://petesbloggerama.blogspot.com




    "" wrote:

    > Problem: When my provider shuts down the SQL Server IIS receives a few
    > error messages and then switches the site to 'SERVICE UNAVAILABLE'.
    >
    > Before IIS kills itself it is friendly enough to send me an error
    > message.
    >
    > ****ERROR MESSAGE 1******
    > System.Data.SqlClient.SqlException: An error has occurred while
    > establishing a connection to the server. When connecting to SQL Server
    > 2005, this failure may be caused by the fact that under the default
    > settings SQL Server does not allow remote connections.
    >
    >
    > This error message happens when the server is offline and my ASP.NET 2
    > code tries to open a connection
    >
    > .....
    > myConnection.Open()
    > .....
    >
    > The last error message I receive is
    >
    > *****ERROR MESSAGE 2*****
    > System.InvalidOperationException: Timeout expired. The timeout period
    > elapsed prior to obtaining a connection from the pool. This may have
    > occurred because all pooled connections were in use and max pool size
    > was reached
    >
    >
    > I am not sure if the ERROR MESSAGE 2 really is about the connection
    > pool, since the sql server is already down. But this might trigger IIS
    > to set my service unavailable.
    >
    >
    >
    > What can I do in my asp.net code to detectd if a SQL server is online?
    >
    >
     
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=, Sep 3, 2006
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sreedhar Vankayala
    Replies:
    2
    Views:
    13,559
    Sreedhar Vankayala
    Feb 25, 2004
  2. Andrew J Gray
    Replies:
    1
    Views:
    9,141
    Teemu Keiski
    Mar 4, 2004
  3. bubberz
    Replies:
    1
    Views:
    536
    Steve C. Orr [MVP, MCSD]
    Aug 6, 2005
  4. Gerry Hickman
    Replies:
    2
    Views:
    1,511
    Gerry Hickman
    Dec 14, 2005
  5. ABC
    Replies:
    1
    Views:
    1,316
    Jeremy S.
    May 12, 2006
Loading...

Share This Page