473,387 Members | 1,603 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Finding instances of SQL Server does not work properly

I am trying to find instances of all the SQL servers on the local network including the machine it
is running from. The servers will be a mix of SQL2000 and SQL2005 once it is ready. I have been
trying it out with the PC on which the program is running also has SQL Server 2005 running on it at
the same time but the code will not pick this instance up. I call the following on the Form Load

Imports Microsoft.SqlServer.Management.Smo

Private Sub GetServers()

Dim dtable As DataTable
Dim drow as DataRow

if myServer <> String.Empty Then
cbServers.Items.Add(myServer) ' Add server we are currently using
End If

dt = SmoApplication.EnumAvailableSqlServers(False) ' this should get the list of servers
For Each dro In dtable.Rows
' populate combo box with server list
if drow(0).ToString <> myServer then cbServers.Items.Add(drow(0).ToString)
Next

End Sub

The server exists and I can use it if I type in the machine name but the above code fails to detect
it.

Any help?
Nov 23 '05 #1
3 4685

Hi John ,

i use DMO for this purpose

set a rerefence to the sql dmo lib and use below code
Dim sqlObj As New SQLDMO.Application

With sqlObj.ListAvailableSQLServers()

For i As Integer = 0 To .Count

MsgBox(.Item(i))

Next

End With

regards

michel posseth [MCP]

"John Veldthuis" <jo***@no.spamo.paradise.net.nz> wrote in message
news:pk********************************@4ax.com...
I am trying to find instances of all the SQL servers on the local network
including the machine it
is running from. The servers will be a mix of SQL2000 and SQL2005 once it
is ready. I have been
trying it out with the PC on which the program is running also has SQL
Server 2005 running on it at
the same time but the code will not pick this instance up. I call the
following on the Form Load

Imports Microsoft.SqlServer.Management.Smo

Private Sub GetServers()

Dim dtable As DataTable
Dim drow as DataRow

if myServer <> String.Empty Then
cbServers.Items.Add(myServer) ' Add server we are currently
using
End If

dt = SmoApplication.EnumAvailableSqlServers(False) ' this should
get the list of servers
For Each dro In dtable.Rows
' populate combo box with server list
if drow(0).ToString <> myServer then
cbServers.Items.Add(drow(0).ToString)
Next

End Sub

The server exists and I can use it if I type in the machine name but the
above code fails to detect
it.

Any help?

Nov 23 '05 #2
On Sat, 19 Nov 2005 11:21:21 +0100, "m.posseth" <mi*****@nohausystems.nl> wrote:

Could not find the reference in the list. I am using VB2005 and .Net 2.0 to do this. Maybe this is
why I cant see it.
I just plugged my laptop into a network which has another instance of SQL on it and now suddenly I
can see the instance on the network and also the one that is on the laptop. Maybe it just does not
work when there is no network connections available but I would have thought it would have used the
local IP address to check as well.

May stick with what I have as I know that when I do publish it the PC on which it will reside will
be connected to the network and have at least 10 servers on it.

Hi John ,

i use DMO for this purpose

set a rerefence to the sql dmo lib and use below code
Dim sqlObj As New SQLDMO.Application

With sqlObj.ListAvailableSQLServers()

For i As Integer = 0 To .Count

MsgBox(.Item(i))

Next

End With

regards

michel posseth [MCP]

"John Veldthuis" <jo***@no.spamo.paradise.net.nz> wrote in message
news:pk********************************@4ax.com.. .
I am trying to find instances of all the SQL servers on the local network
including the machine it
is running from. The servers will be a mix of SQL2000 and SQL2005 once it
is ready. I have been
trying it out with the PC on which the program is running also has SQL
Server 2005 running on it at
the same time but the code will not pick this instance up. I call the
following on the Form Load

Imports Microsoft.SqlServer.Management.Smo

Private Sub GetServers()

Dim dtable As DataTable
Dim drow as DataRow

if myServer <> String.Empty Then
cbServers.Items.Add(myServer) ' Add server we are currently
using
End If

dt = SmoApplication.EnumAvailableSqlServers(False) ' this should
get the list of servers
For Each dro In dtable.Rows
' populate combo box with server list
if drow(0).ToString <> myServer then
cbServers.Items.Add(drow(0).ToString)
Next

End Sub

The server exists and I can use it if I type in the machine name but the
above code fails to detect
it.

Any help?

Nov 23 '05 #3
Hi John ,

happy to hear that you discovered the cause of the problem

DMO is to be used with COM interop ,,,,, so click the com tab and you
would have seen it ( just for future ref )

Regards

Michel

"John Veldthuis" <jo***@no.spamo.paradise.net.nz> wrote in message
news:7f********************************@4ax.com...
On Sat, 19 Nov 2005 11:21:21 +0100, "m.posseth" <mi*****@nohausystems.nl>
wrote:

Could not find the reference in the list. I am using VB2005 and .Net 2.0
to do this. Maybe this is
why I cant see it.
I just plugged my laptop into a network which has another instance of SQL
on it and now suddenly I
can see the instance on the network and also the one that is on the
laptop. Maybe it just does not
work when there is no network connections available but I would have
thought it would have used the
local IP address to check as well.

May stick with what I have as I know that when I do publish it the PC on
which it will reside will
be connected to the network and have at least 10 servers on it.

Hi John ,

i use DMO for this purpose

set a rerefence to the sql dmo lib and use below code
Dim sqlObj As New SQLDMO.Application

With sqlObj.ListAvailableSQLServers()

For i As Integer = 0 To .Count

MsgBox(.Item(i))

Next

End With

regards

michel posseth [MCP]

"John Veldthuis" <jo***@no.spamo.paradise.net.nz> wrote in message
news:pk********************************@4ax.com. ..
I am trying to find instances of all the SQL servers on the local network
including the machine it
is running from. The servers will be a mix of SQL2000 and SQL2005 once
it
is ready. I have been
trying it out with the PC on which the program is running also has SQL
Server 2005 running on it at
the same time but the code will not pick this instance up. I call the
following on the Form Load

Imports Microsoft.SqlServer.Management.Smo

Private Sub GetServers()

Dim dtable As DataTable
Dim drow as DataRow

if myServer <> String.Empty Then
cbServers.Items.Add(myServer) ' Add server we are currently
using
End If

dt = SmoApplication.EnumAvailableSqlServers(False) ' this should
get the list of servers
For Each dro In dtable.Rows
' populate combo box with server list
if drow(0).ToString <> myServer then
cbServers.Items.Add(drow(0).ToString)
Next

End Sub

The server exists and I can use it if I type in the machine name but the
above code fails to detect
it.

Any help?

Nov 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Tristan | last post by:
Im trying to expand a search util by uing regular expression to allow common search criteria such as +-* and phrases "". My understanding of ereg(string pattern, string string, ) is that the...
4
by: Kay Schluehr | last post by:
Hi people, I wonder why the isinstance() function is sensitive about the import path i.e. the result depends not only on the class and the instance but also on how a class is imported? ...
1
by: Bruce | last post by:
I am writing an installer that needs to put a dll file with a bunch of extended stored procedures in the BINN directory. The problem is that if the machine is running multiple instances of SQL...
11
by: Mike | last post by:
Looking to find any information on how to properly configure multiple instances of DB2. This is on Win2k db2 ver 7.2. I am basically looking for information on how the multiple instance settings...
3
by: Tim | last post by:
Hello Everyone I'd like to create a script/program that can locate all servers running DB2, finding out which instances are running/created and what databases are running under them but have...
25
by: Subra | last post by:
Hi, What is the best way to find the 1000 largest numbers from the file having hell lot of entries ? Can you please help me to find out the way ? Do I need to go for B+ trees ?? Please help,...
8
by: =?Utf-8?B?UGV0ZXI=?= | last post by:
I'm trying to get a list of SQL Server Instances thru a VB.NET application. I have tried GetDataSource and SMO. I have also tried using ListSQLSvr.exe from...
7
by: joproulx | last post by:
Hi, I was wondering if there was a way with Reflection to find dynamically if an object was referencing indirectly another object. A simple example would be: Object1 | --Object2 |
275
by: Astley Le Jasper | last post by:
Sorry for the numpty question ... How do you find the reference name of an object? So if i have this bob = modulename.objectname() how do i find that the name is 'bob'
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.