取得SQLSERVEREB服务器列表涵数。


function TForm3.InitFrm: Boolean;
begin
  GetSQLServerList(ListBox1);
  Result:=True;
end;

Function GetSQLServerList(var List: TListBox): boolean;//取得SQLSERVEREB服务器列表涵数。
var
  i: integer;
  SQLServer: Variant;
  ServerList: Variant;
begin
  Result := False;
  List.Clear;
  try
    SQLServer := CreateOleObject('SQLDMO.Application');
    ServerList := SQLServer.ListAvailableSQLServers;
    for i := 1 to Serverlist.Count do
      list.Items.Add (Serverlist.item(i));
      Result := True;
  Finally
    SQLServer := NULL;
    ServerList := NULL;
  end;
end;

你可能感兴趣的:(服务器,sqlserver,function,integer,null,list)