Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > How to check if SQL Server is running via asp.net

Reply
Thread Tools

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

 
 
wwwmike@gmx.ch
Guest
Posts: n/a
 
      09-02-2006
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?

 
Reply With Quote
 
 
 
 
=?Utf-8?B?UmFq?=
Guest
Posts: n/a
 
      09-02-2006
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
"(E-Mail Removed)" 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?
>
>

 
Reply With Quote
 
 
 
 
Juan T. Llibre
Guest
Posts: n/a
 
      09-02-2006
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...b;EN-US;914277
or
http://forums.microsoft.com/MSDN/Sho...71795&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/
===================================
<(E-Mail Removed)> wrote in message news:(E-Mail Removed) ups.com...
> 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?
>




 
Reply With Quote
 
=?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
Guest
Posts: n/a
 
      09-03-2006
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




"(E-Mail Removed)" 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?
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Help. Getting a An error has occurred while establishing a connectionto the server. When connecting to SQL Server 2005, this failure may be causedby the fact that under the default settings SQL Server does not allow remote aboutjav.com@gmail.com ASP .Net 0 05-03-2008 12:43 PM
Long running SQL query via ActiveRecord blocking the entire Ruby process? estebanjang@gmail.com Ruby 5 11-06-2007 11:28 PM
Do the Self-Paced Training Kits: Microsoft SQL Server 2000 include Eval copy of SQL Server? Brian Whiting Microsoft Certification 2 12-29-2005 04:24 AM
Can't connect to SQL Server, using Windows Authentication users of SQL server? help =?Utf-8?B?UmV6YQ==?= ASP .Net 3 06-07-2004 06:42 PM



Advertisments