If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Delphi, C etc > How to list all installed MS SQL Server Name by Delphi?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-14-03, 03:51
king king is offline
Registered User
 
Join Date: May 2003
Posts: 20
Unhappy 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.
Reply With Quote
  #2 (permalink)  
Old 05-21-03, 16:31
SushiFrito SushiFrito is offline
Registered User
 
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
Reply With Quote
  #3 (permalink)  
Old 06-05-03, 04:11
msieben msieben is offline
Registered User
 
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;
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On