DelphiFAQ Home Search:
General :: Programming :: Delphi :: Database
Database development with Delphi. Includes issues with BDE, ADO and InterBase.


This list is sorted by recent document popularity (not total page views).
New documents will first appear at the bottom.

Only the 40 most recently viewed articles are shown.
You can see the full list here.

Featured Article

Dynamically switch the Interbase port


In our environment, we have Interbase servers installed on different machines, which - for security reasons - do not listen on the default port of 3500. Some listen on port 8000 or 7000.
I'm writing a tool that shall connect to various servers (on different ports). How can I accomplish this?


You need to modify the services file which on Windows systems is located in windowssystem32driversetc

The function SelectInterbasePort() as shown below will switch to a different port. For safety I would close connections before switching that file. It might not be a reliable situation that you are connected to multiple servers on different interbase ports simultaneously. (It might work, but I personally have not tested it.)

program Dummy;
 procedure SelectInterbasePort(iPort: integer);
   f: TextFile;
   g: TextFile;
   Line: string;
   sServicesFn: string;
 begin { SelectInterbasePort }
   sServicesFn := GetWindowsDir+'system32driversetcservices';
   AssignFile(f, sServicesFn);
   AssignFile(g, sServicesFn+'.new');
   while not Eof(f) do
     Readln(f, Line);
     if AnsiLowerCase(copy(Line, 1, 6))<>'gds_db' then
       writeln(g, Line);
   end; { not Eof(f) }
   writeln(g, 'gds_db    ', iPort, '/tcp');
   RenameFile(sServicesFn+'.new', sServicesFn);
   Memo1.Lines.Add('switching to port '+IntToStr(iPort));
 end; { SelectInterbasePort }
   SelectInterbasePort (3500);
   // do some work..
   SelectInterbasePort (8000);
   // work on other server

Generated 16:01:07 on Nov 18, 2019