Skip to main content

TcxDBDataController.MasterKeyFieldNames Property

Specifies a list of dataset fields in a master dataset to establish master-detail relationship between two datasets.

Declaration

property MasterKeyFieldNames: string read; write;

Property Value

Type
string

Remarks

To establish master-detail relationships between two datasets you have to create a data controller for each of them and set detail and master key field names via the DetailKeyFieldNames and MasterKeyFieldNames properties of the detail controller. Thus you link two datasets by specific fields. The detail data controller will represent only data that corresponds to a specific record in the master data controller.

Let’s examine two tables: Customers and Orders. The Orders table stores information on orders that are made by different customers. Both tables contain the CustNo field, which uniquely identifies customers. Assume you want to display orders made by customers by navigating through the Customers table. In this case the Customers table is the master table and Orders is the detail table. Create data controllers for the Customers & Orders tables and set the DetailKeyFieldNames and MasterKeyFieldNames properties of the detail data controller to ‘CustNo’. The MasterKeyFieldNames property identifies the CustNo field in the Customers table and the DetailKeyFieldNames property identifies the CustNo field in the Orders table.

To link two tables by several fields, you need to specify these fields in the DetailKeyFieldNames and MasterKeyFieldNames strings, separating them by a semicolon.

If the detail data controller is bound to a dataset other than a parameterized query, you have to sort the records by the fields identified by the DetailKeyFieldNames property. In this case, a detail data controller will correctly retrieve all the corresponding records. Otherwise, not all records can be located and retrieved from the detail dataset.

See Also