Results 1 to 3 of 3
  1. #1
    Join Date
    May 2003
    Posts
    20

    Unhappy Unanswered: How to list all installed MS SQL Server Name by Delphi?

    How to list all installed MS SQL Server Name by Delphi?
    I hope someone could give me suggestion.

  2. #2
    Join Date
    May 2003
    Location
    Sao Paulo, Brazil
    Posts
    6
    you can shell "Net Start >> C:\TEMP\file.txt" and read this file.

    Find the MSSQL string

    You can find
    "MSSQLServer"
    "MSSQL$INSTANCE"
    "MSSQLServer$INSTANCE"

    []'s
    Sushi

  3. #3
    Join Date
    Feb 2003
    Location
    Germany
    Posts
    53

    Re: How to list all installed MS SQL Server Name by Delphi?

    Hi,

    we use something like this:

    Code:
    procedure FindSQLServers( aList:tStrings );  // try an (inofficial) connect to sqlserver on port 1434 
    var UDP:tidUDPClient;
        IP,T,D,Peer, REC,S:String;
        Port:Integer;
        ServerName, InstanceName, TCPPort, Version :String;
    begin
      UDP:=tidUDPCLient.Create(nil);
      try
        S:=GStack.LocalAddress;
        IP:=Fronttoken(S,'.')+'.'+Fronttoken(S,'.')+'.'+Fronttoken(S,'.')+'.255';
        UDP.Host:= IP;
        UDP.Port:=1434;
        UDP.BroadcastEnabled:=True;
        UDP.ReceiveTimeout:=6000;
        aList.Clear;
        UDP.Send(#2);
        repeat
          ServerName:='';
          InstanceName:='';
          REC := UDP.ReceiveString( Peer, Port );
          S:=Copy(REC,4,MaxInt);
          while length(S)>0 do begin
            if S=';' then begin
              s:='';
            end else begin
              T:=Fronttoken(S,';');
              D:=Fronttoken(S,';');
              if T='SERVERNAME' then Servername:=D else
              if T='INSTANCENAME' then InstanceName:=D else
              if T='TCP' then TCPPort:=D else
              if T='VERSION' then Version:=D;
            end;
          end;
          if ServerName<>'' then begin
            if InstanceName<>'MSSQLSERVER' then S:=Servername+'\'+InstanceName
                                           else S:=Servername;
    //        aList.Add(S+' ('+Peer+'.'+TCPPort+') Version '+Version );
            aList.Add(S);
          end;
        until REC='';
      finally
        UDP.Free;
      end;
    end;

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •