Reputation: 689
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:
Any help with this issue will be highly appreciated.
Upvotes: 0
Views: 150
Reputation: 55
I had this problem with Delphi 11 Developer Edition. I could connect outside the IDE, but running from the IDE gave the error "Unavailable Database". I solved it by deleting the IDE Interbase environment variables INTERBASE, IB_PROTOCOL, and the Interbase redistributable one (I forget the name), from Tools | IDE | Environment Variables - User System Overrides. I don't know how they got there, but they confused the IDE as to where the Interbase server was.
You MUST restart the IDE after making the change!
David
Upvotes: 1