Wednesday, March 21, 2012

Detect servers on the network?

I'm wondering how to detect SQL servers on the network, the way Enterprise
Manager locates servers when it populates combo boxes or list boxes with
active servers on the network. Can anybody give me a hint? Some C# code
would be a plus. Thanks!
Hi,
Execute the below command from command prompt:-
ISQL -L
Thanks
Hari
SQL Server MVP
"William Sullivan" <WilliamSullivan@.discussions.microsoft.com> wrote in
message news:570D002D-3661-4E08-9F22-DC8B62DE2CBE@.microsoft.com...
> I'm wondering how to detect SQL servers on the network, the way Enterprise
> Manager locates servers when it populates combo boxes or list boxes with
> active servers on the network. Can anybody give me a hint? Some C# code
> would be a plus. Thanks!
|||Sorry, I meant progmatically, not at the command line. The idea being that I
detect available servers on the network in order to populate a combo box with
their names. Thanks!
"Hari Prasad" wrote:

> Hi,
> Execute the below command from command prompt:-
> ISQL -L
>
> --
> Thanks
> Hari
> SQL Server MVP
>
>
> "William Sullivan" <WilliamSullivan@.discussions.microsoft.com> wrote in
> message news:570D002D-3661-4E08-9F22-DC8B62DE2CBE@.microsoft.com...
>
>
|||Try using COM interop and the SQLDMO ( SQL Server Distributed Management
Objects ).
Heres a sample in C#
http://www.csharphelp.com/archives2/archive342.html
"William Sullivan" <WilliamSullivan@.discussions.microsoft.com> wrote in
message news:570D002D-3661-4E08-9F22-DC8B62DE2CBE@.microsoft.com...
> I'm wondering how to detect SQL servers on the network, the way Enterprise
> Manager locates servers when it populates combo boxes or list boxes with
> active servers on the network. Can anybody give me a hint? Some C# code
> would be a plus. Thanks!
|||Yes, quite. That's the ticket! Thanks much!
"Darren" wrote:

> Try using COM interop and the SQLDMO ( SQL Server Distributed Management
> Objects ).
> Heres a sample in C#
> http://www.csharphelp.com/archives2/archive342.html
>
> "William Sullivan" <WilliamSullivan@.discussions.microsoft.com> wrote in
> message news:570D002D-3661-4E08-9F22-DC8B62DE2CBE@.microsoft.com...
>
>
|||Hello,
I tried this. but i am getting the following error ' QueryInterface for
interface SQLDMO.NameList failed.' I have reference SQLDMO.dll file in my
project.
here is my code--
Dim sqlapp As SQLDMO.Application
sqlapp = New SQLDMO.ApplicationClass
Dim sqlservers As SQLDMO.NameList
sqlservers = sqlapp.ListAvailableSQLServers
Dim i As Integer
Dim srv As Object
For i = 0 To sqlservers.Count
srv = sqlservers.Item(i + 1)
cboServers.Items.Add(srv)
Next
Thanks,
"Darren" wrote:

> Try using COM interop and the SQLDMO ( SQL Server Distributed Management
> Objects ).
> Heres a sample in C#
> http://www.csharphelp.com/archives2/archive342.html
>
> "William Sullivan" <WilliamSullivan@.discussions.microsoft.com> wrote in
> message news:570D002D-3661-4E08-9F22-DC8B62DE2CBE@.microsoft.com...
>
>

No comments:

Post a Comment