arnet11 0 Newbie Poster

Hi all,

I need to build a application in which i have to test wheather sql server
2000 is connected or not.I cant be dependent on any query using master database as user might not have access to it.
I used following code

Try
Dim objIPHost As New System.Net.IPHostEntry
objIPHost = System.Net.Dns.Resolve(txtServer.Text)
Dim objAddress As System.Net.IPAddress
objAddress = objIPHost.AddressList(0)

Dim objTCP As System.Net.Sockets.TcpClient = _
New System.Net.Sockets.TcpClient
objTCP.Connect(objAddress, 1433)
objTCP.Close()
objTCP = Nothing
objAddress = Nothing
objIPHost = Nothing
MsgBox("Connection with server successful.", MsgBoxStyle.Information, strMsgCaption)
Catch ex As Exception
MsgBox("Connection with server failed.", MsgBoxStyle.Information, strMsgCaption)
Exit Sub
End Try

in this i have used default port no for sql server,but it will not be always the case.

so if any one tell how to generalise this.