Search code examples
delphicomponentsfiredac

Component Build - Required package used for TFDConnection not found


I'm trying to build a new component and I would like to create a property where I would like to associate a TFDConnection object like this:

uses
  System.SysUtils, System.Classes, System.Types, System.UITypes,
  Vcl.Dialogs, Vcl.Graphics,
  ColnEdit, DesignIntf, DesignEditors,
  VirtualTrees, FireDac;

type
  TMyComp = class(TComponent)
  private
    FFDConnection: TFDConnection;
    procedure SetFDConnection(Value: FFDConnection);
  protected
    { Protected declarations }
  public
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
    property FDConnection: TFDConnection read FFDConnection write SetFDConnection;
  end;

My problem comes from the fact that FireDac package used inside the component package is not found.

package MyPackage;

...

requires
  rtl,
  vcl,
  VirtualTreesR,
  DesignIde,
  dclFireDAC230; //<--- this package it's not recognized

contains
  MyComp in 'MyComp.pas';

end.

[dcc32 Fatal Error] MyPackage.dpk(36): E2202 Required package 'dclFireDAC230' not found

I take this name from here: enter image description here

How can I identify the name of the required package corresponding to TFDConnection?


Solution

  • Inspired by the answers, I found out that in place of FireDac I should use inside the code of my component FireDAC.Comp.Client like this:

    uses
      System.SysUtils, System.Classes, System.Types, System.UITypes,
      Vcl.Dialogs, Vcl.Graphics,
      ColnEdit, DesignIntf, DesignEditors,
      VirtualTrees, FireDAC.Comp.Client;
    

    In fact in a standard app when you drag and drop on a form a TFDConnection, Delphi automatically add to uses all this bellow modules:

    uses
      ...
      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.VCLUI.Wait,
      Data.DB, FireDAC.Comp.Client
    

    Following the link we can see that TFDConnection is defined inside FireDAC.Comp.Client.

    Now, by adding FireDAC.Comp.Client to my component, when I try to build my component, Delphi is doing a smart thing by suggesting me what to add to require section from the package.

    enter image description here

    After clicking Ok, Delphi will automatically change the code to this:

    requires
      rtl,
      vcl,
      VirtualTreesR,
      DesignIde,
      dbrtl,
      FireDAC,
      FireDACCommonDriver,
      FireDACCommon;
    

    .dcu files seems to be located to: C:\Program Files (x86)\Embarcadero\Studio\17.0\lib...