List SQL servers in a network
- From: "Oliver Braun" <O.Braun@xxxxxxxxx>
- Date: Fri, 26 Aug 2005 09:28:37 +0200
I know this is a very common issue and I found a lot of hints on this topic
in www but I did not find a very good solution for this task.
Most of the solutions use SQLDMO to list all sql servers in the network like
this C# code:
public static string[] GetAvailableSQLServers()
{
// declare arraylist to hold results
ArrayList servers = new ArrayList();
// create and initialize necessary SQL access objects (see SQLDMO.dll)
SQLDMO.ApplicationClass sqlApp = new SQLDMO.ApplicationClass();
SQLDMO.NameList sqlServers = sqlApp.ListAvailableSQLServers();
for(int i=0;i<sqlServers.Count;i++)
{
object srv = sqlServers.Item(i + 1);
if(srv != null)
{
servers.Add(srv.ToString());
}
}
// convert arraylist to string array and return it
return servers.ToArray(Type.GetType("System.String")) as string[];
}
But there are two main problems:
- this does not work with Windows XP (see SQLDMO documentation: it works
only with Windows NT 4.0 and 2000)
- it does not work on a local PC that is not connected to the network (it
does not show any instance that is available)
Does anybody have a better solution for this task?
.
- Follow-Ups:
- RE: List SQL servers in a network
- From: Jakob Christensen
- Re: List SQL servers in a network
- From: Benny S. Tordrup
- RE: List SQL servers in a network
- Prev by Date: Re: connect to internet from a windows service
- Next by Date: Re: Mediator design pattern
- Previous by thread: Synchronization bool shared fields
- Next by thread: Re: List SQL servers in a network
- Index(es):
Relevant Pages
|