FireDAC.Comp.Client.TFDCustomQuery.DataSource

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

property DataSource: TDataSource read GetDS write SetDS;

C++

__property Data::Db::TDataSource* DataSource = {read=GetDS, write=SetDS};

Properties

Type Visibility Source Unit Parent
property public
FireDAC.Comp.Client.pas
FireDAC.Comp.Client.hpp
FireDAC.Comp.Client TFDCustomQuery

Description

Specifies the data source object from which the associated dataset to get matching field values to the details dataset parameters.

Use the DataSource property to automatically fill parameters in a query with field values from another dataset. Parameters that have the same name as the fields in the other dataset are filled with the field values. Parameters with names that are not the same as the fields in the other dataset do not automatically get values, and must be programmatically set. 

When the master dataset current position is changed or the data in the current record of the master dataset is changed, then this dataset (detail dataset) reopens the query using new master dataset field values. If that is not desired behavior or you must quickly walk through the master dataset, then use DisableControls / EnableControls on the master dataset.

Example

MasterQuery.Open('select * from {id Orders}');
MasterSource.DataSet := MasterQuery;
DetailQuery.DataSource := MasterSource;
DetailQuery.Open('select * from {id Order Details} where OrderID = :OrderID');
// here :OrderID parameter of DetailQuery will get the current value of OrderID
// field from MasterQuery

See Also