User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the MS SQL section within the Web Development category of DaniWeb, a massive community of 456,563 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,528 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our MS SQL advertiser: Programming Forums
Views: 1386 | Replies: 0
Reply
Join Date: Jan 2007
Posts: 1
Reputation: arnet11 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
arnet11 arnet11 is offline Offline
Newbie Poster

Test Connectivity

  #1  
Jan 30th, 2007
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.
AddThis Social Bookmark Button
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb MS SQL Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the MS SQL Forum

All times are GMT -4. The time now is 5:45 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC