PC Review Forums Newsgroups Microsoft DotNet Microsoft ADO .NET HOWTO: List SQL Servers on Local Machine

Reply

HOWTO: List SQL Servers on Local Machine

 
Thread Tools Rate Thread
Old 10-04-2006, 03:37 PM   #1
=?Utf-8?B?U2NvdHQ=?=
Guest
 
Posts: n/a
Default HOWTO: List SQL Servers on Local Machine


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
  Reply With Quote
Old 10-04-2006, 05:01 PM   #2
William \(Bill\) Vaughn
Guest
 
Posts: n/a
Default Re: HOWTO: List SQL Servers on Local Machine

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.
__________________________________

"Scott" <Scott@discussions.microsoft.com> wrote in message
news:5B8FB955-666F-4848-8A64-216DF5C8CBC6@microsoft.com...
> 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



  Reply With Quote
Old 10-04-2006, 05:12 PM   #3
=?Utf-8?B?U2NvdHQ=?=
Guest
 
Posts: n/a
Default Re: HOWTO: List SQL Servers on Local Machine

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.

"William (Bill) Vaughn" wrote:

> 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?
>

  Reply With Quote
Old 11-04-2006, 04:57 PM   #4
William \(Bill\) Vaughn
Guest
 
Posts: n/a
Default Re: HOWTO: List SQL Servers on Local Machine

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.
__________________________________

"Scott" <Scott@discussions.microsoft.com> wrote in message
news:A9219BF1-C1EA-44C6-AF25-70DC6EABAA63@microsoft.com...
> 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.
>
> "William (Bill) Vaughn" wrote:
>
>> 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?
>>



  Reply With Quote
Old 11-04-2006, 05:23 PM   #5
Jeff Dillon
Guest
 
Posts: n/a
Default Re: HOWTO: List SQL Servers on Local Machine

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

"William (Bill) Vaughn" <billvaRemoveThis@nwlink.com> wrote in message
news:uYBIpCYXGHA.3724@TK2MSFTNGP02.phx.gbl...
> 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.
> __________________________________
>
> "Scott" <Scott@discussions.microsoft.com> wrote in message
> news:A9219BF1-C1EA-44C6-AF25-70DC6EABAA63@microsoft.com...
>> 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.
>>
>> "William (Bill) Vaughn" wrote:
>>
>>> 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?
>>>

>
>



  Reply With Quote
Old 12-04-2006, 07:05 PM   #6
=?Utf-8?B?U2NvdHQ=?=
Guest
 
Posts: n/a
Default Re: HOWTO: List SQL Servers on Local Machine

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.

"Jeff Dillon" wrote:

> 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

  Reply With Quote
Old 12-04-2006, 08:07 PM   #7
William \(Bill\) Vaughn
Guest
 
Posts: n/a
Default Re: HOWTO: List SQL Servers on Local Machine

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.
__________________________________

"Scott" <Scott@discussions.microsoft.com> wrote in message
news:CF0776D7-0F57-4A1F-9E77-67C175FDC9AF@microsoft.com...
> 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.
>
> "Jeff Dillon" wrote:
>
>> 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



  Reply With Quote
Old 19-04-2006, 07:09 AM   #8
Thomas Due
Guest
 
Posts: n/a
Default Re: HOWTO: List SQL Servers on Local Machine

William (Bill) Vaughn wrote:

>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
  Reply With Quote
Old 19-04-2006, 07:31 AM   #9
William \(Bill\) Vaughn
Guest
 
Posts: n/a
Default Re: HOWTO: List SQL Servers on Local Machine

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.
__________________________________

"Thomas Due" <tdue@mail_remove_.dk> wrote in message
news:uHwOWf3YGHA.1580@TK2MSFTNGP02.phx.gbl...
> William (Bill) Vaughn wrote:
>
>>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



  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off