【发布时间】:2018-08-20 15:21:09
【问题描述】:
DelphiXE 10.2.2
在这里检查 old http://codeverge.com topic 那时在哪里工作,但现在是
ResultConnectionDef 用于获取有关已建立连接(服务器和端口)的信息。
procedure TMainForm.UpdateCaption;
begin
Caption := Format('Truice %s - Connection: %s:%d / %s', [VERSION_EXE, MyTrinityConnection.HostName, MyTrinityConnection.Port, GetDBVersion]);
Application.Title := Caption;
end;
使用 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;
结果:
'IFDStanConnectionDef' does not contain a member named 'Server'
'IFDStanConnectionDef' does not contain a member named 'Port'
问题:
- FireDAC 是否对这部分进行了更改?
- 收集服务器和端口以进行活动连接的最佳方法是什么?
维多利亚解决方案后的最终代码,如下所示:
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;
【问题讨论】: