Thread: Check SQL server availability
-
06-30-2006 #1
This C# function helps you check if SQL Server is running fine on a particular server and port. Useful to use on app startup, or for troubleshooting firewall problems after a Windows SP2 installation.
using System.Net;
using System.Net.Sockets;
public bool CheckSQLServer(string SQLHost, int SQLPort)
{
try
{
IPHostEntry IPHost = new IPHostEntry();
IPHost = Dns.Resolve(SQLHost);
IPAddress IPAddr = IPHost.AddressList[0];
TcpClient TcpCli = new TcpClient();
TcpCli.Connect(IPAddr, SQLPort);
TcpCli.Close();
return true;
}
catch
{
return false;
}
}
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Similar Threads
-
Using SMTP Command to check Email Connections.
By Manuel_ in forum TroubleShootingReplies: 0Last Post: 06-25-2006, 11:45 AM -
Prevent the IIS SMTP Virtual Server from Relaying E-mail Messages
By Manuel_ in forum Windows Dedicated ServersReplies: 0Last Post: 06-22-2006, 04:36 PM -
Configure SQL database in MS Enterprise Manager
By Manuel_ in forum Windows Web Hosting Discussion ForumReplies: 0Last Post: 06-03-2006, 05:58 AM -
Move large domain to new server
By Manuel_ in forum TroubleShootingReplies: 0Last Post: 06-03-2006, 05:39 AM


LinkBack URL
About LinkBacks






Reply With Quote
