HOWTO: List SQL Servers on Local Machine

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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.
__________________________________
 
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.
 
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.
__________________________________
 
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
 
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.
 
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.
__________________________________
 
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
 
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.
__________________________________
 
Back
Top