下面是用C#语言书写的用于列举局域网中可用的Microsoft SQL Server的类:
using System;
using System.Collections.Generic;
using System.Text;
namespace AllSqlServer
{
class Program
{
static void Main(string[] args)
{
SQLDMO.NameList names;
SQLDMO.ApplicationClass ac = new SQLDMO.ApplicationClass();
names = ac.ListAvailableSQLServers();
string[] serverList = new string[names.Count];
for (int i = 0; i serverList.Length; i++)
{
serverList[i] = names.Item(i);
}
foreach (string str in serverList)
{
Console.WriteLine(str);
}
Console.ReadLine();
}
}
}