作用:获取MS SQLServer服务器列表
{------------------------------------}
{ MS SQLServer服务器列表 }
{ Uses ComObj }
{------------------------------------}
procedure GetSQLServerLsit(sSList:TStrings);
var
SQLServer: Variant;
ServerList: Variant;
i, nServers: integer;
begin
sSList.Clear;
try
SQLServer := CreateOleObject('SQLDMO.Application');
ServerList := SQLServer.ListAvailableSQLServers;
nServers := ServerList.Count;
for i := 1 to nservers do
sSList.Add(ServerList.Item(i));
SQLServer := NULL;
serverList := NULL;
except
Application.MessageBox('您当前的机器没有安装SQL Server,无法导入SQL Server服务器列表,'+
#13+#10+'请直接输入SQL Server服务器名称!','信息提示',MB_OK+MB_ICONINFORMATION);
end;
end;