DelphiXE 10.2.2
Was checking here old http://codeverge.com topic where back then was working, but now with
ResultConnectionDef for getting information about established connection (Server and Port).
procedure TMainForm.UpdateCaption;
begin
Caption := Format('Truice %s - Connection: %s:%d / %s', [VERSION_EXE, MyTrinityConnection.HostName, MyTrinityConnection.Port, GetDBVersion]);
Application.Title := Caption;
end;
With FireDac:
uses FireDAC.Phys.MySQLDef, FireDAC.Stan.Intf, FireDAC.Stan.Option, FireDAC.Stan.Error, FireDAC.UI.Intf, FireDAC.Phys.Intf, FireDAC.Stan.Def, FireDAC.Stan.Pool, FireDAC.Stan.Async, FireDAC.Phys, FireDAC.Phys.MySQL, FireDAC.VCLUI.Wait, FireDAC.Comp.UI, FireDAC.Comp.Client, FireDAC.Stan.Param, FireDAC.DatS, FireDAC.DApt.Intf, FireDAC.DApt, FireDAC.Comp.DataSet, FireDAC.Comp.Script, FireDAC.Comp.ScriptCommands, FireDAC.Stan.Util;
procedure TMainForm.UpdateCaption;
begin
Caption := Format('Truice %s - Connection: %s:%d / %s', [VERSION_EXE, MyTrinityConnection.ResultConnectionDef.Server, MyTrinityConnection.ResultConnectionDef.Port, GetDBVersion]);
Application.Title := Caption;
end;
Result:
'IFDStanConnectionDef' does not contain a member named 'Server'
'IFDStanConnectionDef' does not contain a member named 'Port'
Questions:
- Are there any changes to FireDAC where this part was changed?
- What is best method to gather Server and Port for active connection?
Final code after Victorias solution, looks so:
procedure TMainForm.UpdateCaption;
var
Server: string;
Port: Integer;
begin
Server := TFDPhysMySQLConnectionDefParams(MyTrinityConnection.ResultConnectionDef.Params).Server;
Port := TFDPhysMySQLConnectionDefParams(MyTrinityConnection.ResultConnectionDef.Params).Port;
Caption := Format('Truice %s - Connection: %s:%d / %s', [VERSION_EXE, Server, Port, GetDBVersion]);
Application.Title := Caption;
end;