HOWTO: List SQL Servers on Local Machine

G

Guest

Hi All,

I need to retrieve a list of SQL servers that are running on a local machine.

I have tried using:
SqlDataSourceEnumerator instance = SqlDataSourceEnumerator.Instance;
System.Data.DataTable table = instance.GetDataSources();
but have found that it returns servers on the entire network not on the
local machine.

Is there some other C# API that can be used to get a list of SQL servers
that are running on the local machine?

Thanks in advance for any help,
Scott
 
W

William \(Bill\) Vaughn

I have used these methods many times to demonstrate access to servers on the
local machine and anywhere else visible on the net. Are the local servers
configured so as to make them "visible"? Is the SqlBrowser service running?
Are the ports and protocols enabled?

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
 
G

Guest

Hi Bill,

Yes, the local servers are visible and SqlBroswer service is running.
Not sure about ports and protocols. However the two servers I am intersted
in(SQLEXPRESS and MSSQLSSERVER-MSDE) are visible SQL Server Configuration
Manager.
 
W

William \(Bill\) Vaughn

Did you run the SQL Server Surface Area Configuratoin tool?

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
 
J

Jeff Dillon

Bill, I think he is saying he is getting ALL servers. He just wants to
enumerate those on the local machine. He is getting these, plus the rest of
the network, too

Jeff
 
G

Guest

Jeff and Bill,

Yes, what I would like to be able to do is have initially a list of only the
SQL servers that are local to the machine.
Similar to the dialog the comes up when running Micorsoft SQL Server
Management Studio: It's initial dropdown shows (which is very fast):
MYMACHINENAME/SQLEXPRESS
MYMACHINENAME
<Browse for more...>
Choosing "Browse for more..." then launches the search for all servers but
is quite slow depending on the number of servers it searches through on the
network.

Note I was not seeing even my local machine in the list of all servers but
this was due to some strange VPN problem.
 
W

William \(Bill\) Vaughn

Ah. In that case, filter the returned table using a DataView based on the
local machine name...

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
 
T

Thomas Due

William said:
Ah. In that case, filter the returned table using a DataView based on
the local machine name...

Look it up in the registry?

--
Thomas Due
Posted with XanaNews version 1.18.1.3

"Victorious warriors win first and then go to war, while defeated
warriors go to war first and then seek to win."
-- Sun-tzu, The Art of War. Strategic Assessments
 
W

William \(Bill\) Vaughn

See the My and Application classes.

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top