Click here to Skip to main content
15,893,588 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
Hello,

I want to check if database server is available or not in my code.

I am using asp.net C# 4.0

Thank you
Posted
Comments
Amir Mahfoozi 26-Dec-11 0:07am    
you can use a try catch block :)

1 solution

To check if a server is available you can use Ping to see if the server address exists (this will only work if ping has not been blocked by a firewall) : http://msdn.microsoft.com/en-us/library/system.net.networkinformation.ping.aspx[^]

The only real way to see if the database engine is working on a server is try to connect to it.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900