Page 1 of 1

Masterdetail per Mastersource or Paramvalues

Posted: Mon 29 Jun 2015 19:29
by norwegen60
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

Re: Masterdetail per Mastersource or Paramvalues

Posted: Tue 30 Jun 2015 09:53
by AlexP
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).

Re: Masterdetail per Mastersource or Paramvalues

Posted: Tue 30 Jun 2015 18:58
by norwegen60
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

Re: Masterdetail per Mastersource or Paramvalues

Posted: Wed 01 Jul 2015 09:24
by AlexP
Both solutions are correct , and it is up to you what approach to choose for work with Master-Detail.