Search code examples
delphidelphi-xe8interbase

Connecting from a Delphi app to an InterbaseXE7 server on another machine


I have XE8 and the version of InterbaseXE7 that comes with it installed on two machines, A & B. Using IBX or DBX I can connect to the IB server running on the same machine and access its databases without any problem. Btw, I am not a regular IB user.

I had no luck at all connecting from a Delphi app on machine A to an IB database on machine B: I got all manner of errors including a mystifying one about not being able to find the file specified (despite doing a DIR from a CMD prompt to verify that I had the name right) until I discovered that in those circumstances (connecting to a remote server), the database name has to be capitalized in the Delphi app on A exactly as it is on the db host B.

So, assuming there is no way to configure IB and/or IBX to avoid this case-sensitivity, how can I programmatically retrieve a list of the database names, correctly capitalized, on B (assuming I have no access to B's file-system) from a Delphi app on A?

I've tried using the TIBServerProperties component to do this but using code like this:

procedure TForm1.btnPropertiesClick(Sender: TObject);
var
  S : String;
begin
  IBServerProperties1.Active := True;
  IBServerProperties1.FetchDatabaseInfo;
  S := IBServerProperties1.DatabaseInfo.DbName[0];
  Caption := S;
end;

, the database names are returned from the IB host server in all capitals, which obviously doesn't solve the problem of finding their correct capitalizations.


Solution

  • It turns out that the TIBServerProperties can get DB Aliases from a remote server with the correct capitalization, but not using the DatabaseInfo property. The information can be obtained from its AliasInfo property instead (one of those things that's kind-of obvious with the benefit of hindsight), as shown below.

    procedure TForm1.btnPropertiesClick(Sender: TObject);
    var
      S : String;
      i : Integer;
    begin
      IBServerProperties1.Active := True;
      IBServerProperties1.FetchAliasInfo;
      for i :=0 to IBServerProperties1.AliasCount - 1 do begin
        S := IBServerProperties1.AliasInfo[i].Alias;  // <- the .Alias has the
         // same capitalization as on the server
        S := S + ' ' + IBServerProperties1.AliasInfo[i].DBPath;
        Memo2.Lines.Add(S);
      end;
    end;
    

    , which is good enough for my immediate purpose.

    I'd still be interested to know, though, if there is an IB configuration parameter or similar that avoids the case-sensitivity that provoked my q.