var i: integer; sRetValue: String; SQLServer: Variant; ServerList: Variant; Result:Boolean; begin Result := False; lst1.Clear; try try SQLServer := CreateOleObject('SQLDMO.Application'); ServerList := SQLServer.ListAvailableSQLServers; for i := 1 to Serverlist.Count do if serverlist.item(i)='(local)' then begin lst1.Items.Add(serverlist.item(i)); Result := True; end else begin lst1.Items.Add(serverlist.item(i)); end; except showmessage('对非起,sqlserver无安装!'); end; Finally SQLServer := NULL; ServerList := NULL; end; if Result=False then showmessage( '对不起,sqlserver服务未启动! '); |