Masterdetail per Mastersource or Paramvalues

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
norwegen60
Posts: 19
Joined: Wed 15 Dec 2010 13:12

Masterdetail per Mastersource or Paramvalues

Post by norwegen60 » Mon 29 Jun 2015 19:29

Hello together,

I use TUniQuery within Delphi XE3. Now I want to know if there is a difference to make a master/detail connection using

Code: Select all

Mastersource := UniQueryMaster;
Masterfields := 'ID';
Detailfields := 'ID2Master'
or to make it with

Code: Select all

procedure UniQueryMasterAfterScroll(DataSet: TDataSet);
begin
  UniQueryDetail.Params.ParamValues['ID2Master'] := UniQueryMaster.FieldByName('ID').AsValue;
  if not UniQueryDetail.Active then
    UniQueryDetail.Open
  else
    UniQueryDetail.Refresh;
end;
best regards
Gerd

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Masterdetail per Mastersource or Paramvalues

Post by AlexP » Tue 30 Jun 2015 09:53

Hello,

If you are using the first approach (via DataSet properties), then in the Detail query there will be automatically added a condition for selection of the required records only, according to the value in the Master DataSet. Parameter values will also be added when navigating through Master DatasSet records. However, if the Detail DataSet is not open, then it won't be open when navigating through Master DataSet records.
When using the second approach, you will have to write a query for the Detail DataSet (manually taking into account parameters).

norwegen60
Posts: 19
Joined: Wed 15 Dec 2010 13:12

Re: Masterdetail per Mastersource or Paramvalues

Post by norwegen60 » Tue 30 Jun 2015 18:58

Hello,

I know how to use it and both is running. The question is only:

What is from the technical side the better solution

best regards
Gerd

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Masterdetail per Mastersource or Paramvalues

Post by AlexP » Wed 01 Jul 2015 09:24

Both solutions are correct , and it is up to you what approach to choose for work with Master-Detail.

Post Reply