【问题标题】:fireDAC access connection object like in BDEfireDAC 访问连接对象,如 BDE
【发布时间】:2015-04-10 18:28:21
【问题描述】:

在下面的代码 sn-p 中,使用 Sessions 对象为 TQuery 分配了一个 DatabaseName。 您能否建议我们如何在 fireDAC 中进行以下操作或类似操作?

TmpQuery := TQuery.Create(nil);
try
  with TmpQuery do
  begin
    SessionName := Sessions.CurrentSession.SessionName;
    DatabaseName := Sessions.CurrentSession.Databases[0].DatabaseName;
    SQL.Add('select tendr_type, tendr_code');
    SQL.Add('from asatendr where tendr_status="A" ');
    Open;
    while not EOF do
    begin // do the name value pair so i can find them...
      FaTenderList.Add(Trim(Fields[0].AsString) + '=' + Trim(Fields[1].AsString));
      Next;
    end;
    Close;

在firedac 中,我们有TFDManager、TFDConnection、TFDQuery 对象。我只想知道不同 .pas 文件中的多个 TFDQueries 如何访问类似的连接。这是如何在 fireDAC 中管理的?

【问题讨论】:

  • SessionName 在 FireDAC 中不存在。带有 DatabaseName 的行应替换为: ConnectionName := FDManager.Connections[0].ConnectionName;

标签: delphi informix delphi-xe5 firedac


【解决方案1】:

我已经使用 FireDAC TFDManager 对象解决了这个问题。

在我正在使用的项目文件中:

ConnectionName := FDManager.Connections[0].ConnectionName; 

而且它有效。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-19
    • 1970-01-01
    • 2017-08-08
    相关资源
    最近更新 更多