Icon DataSource Property

property DataSource: TDataSource

Usage

The DataSource property specifies the TDataSource component from which to extract current field values to use in the identically-named parameters in the query's SQL statement specified via the SQL property. This allows you to automatically fill parameters in a query with fields values from another data source. Parameters that have the same name as fields in the other data source are filled with the field values. Parameters with names that are not the same as fields in the other dataset do not automatically get values, and must be set by the application manually.

DataSource must point to a TDataSource component linked to another dataset component; it cannot point to this TDBISAMQuery component. The dataset specified in the TDataSource component's DataSet property must be created, populated, and opened before attempting to bind parameters. Parameters are bound by calling the Prepare method prior to executing the query using the ExecSQL or Open method. If the SQL statement used by the query does not contain parameters, or all parameters are bound by the application using the Params property or the ParamByName method, the DataSource property need not be assigned.

If the SQL statement specified in the SQL property of the TDBISAMQuery component is a SELECT statement, the query is executed using the new field values each time the record pointer in the other data source is changed. It is not necessary to call the Open method of the TDBISAMQuery component each time. This makes using the DataSource property to dynamically filter a query result set useful for establishing master-detail relationships. Set the DataSource property in the detail query to the TDataSource component for the master data source.

Information If the SQL statement contains parameters with the same name as fields in the other dataset, do not manually set values for these parameters. Any values manually set, either by using the Params property or the ParamByName method, will be overridden with automatic values.
Image