FireDAC database unavailable when trying to connect

32 views Asked by At

When attempting to make a connection (named MyConnection) on the fly with Interbase server I get the message unavailable database.

Instead, it works fine if I assign a previosuly declared TFDConnection (named FDConnection1) to the connection variable.

I also assigned all properties of FDConnection1 to MyConnection attempting to make them identical.

Still I am getting the same error message.

So I am presuming that there is some unknown twist that I could not find in my researches, that establishes the connection succesfully when assigning a previosuly declared TFDConnection to the connection variable.

Follows code snippets:

working code

...
implementation
...
var MyConnection : TFDConnection;
...
procedure MakeConnection;
begin
  MyConnection := dmConn.FDConnection1; // resides in a data module
  MyConnection.Connected := True; // works fine
  {dmConn.FDConnection1 properties
     Name        = FDConnection1
     DriverName  = IB
     LoginPrompt = False
     Params 
       Database = C:\MyDatabase
       DriverId = IB
       Password = masterkey
       UserName = SYSDBA
       InstanceName = instance2 // name of the server instance
       OsAuthent    = No
       Port         = 3050
  }
End;

not working code

...
implementation
...
var MyConnection : TFDConnection;
...
procedure MakeConnection;
begin
  MYConnection := TFDconnection.Create (Self);
  with MyConnection do begin
       Name        := 'MyConnection1';
       DriverName  := 'IB';
       LoginPrompt :=  False;
       with Params do begin
            Clear;
            Database := 'C:\MyDatabase';
            DriverId := 'IB';
            Password := 'masterkey';
            UserName := 'SYSDBA';
            Add ('InstanceName = instance2'); // name of the server instance        Add ('OsAuthent    = No');
            Add ('Port         = 3050');
       end;
       Connected := True; // error message at this point
   end;
end;

As you can see, all properties are exactly the same.

Follows error message:

enter image description here

Any help with this issue will be highly appreciated.

0

There are 0 answers