Skip to main content

TcxDBDataController.KeyFieldNames Property

Specifies one or more key field names separated by a semicolon.

Declaration

property KeyFieldNames: string read; write;

Property Value

Type
string

Remarks

Use this property to specify a semicolon-separated list of key field names which uniquely identify each dataset record. You should specify key field names in the following cases:

  • If you want to perform in-sync operations on a bound dataset in a detail data controller, such as editing and adding records;

  • If you need to delete several selected records from a bound dataset;

  • If you want to speed up record navigation when data in your grid control is synchronized with a bound dataset.

Performance Tips

Consider the following tips to understand key field specifics and improve performance when using the KeyFieldNames property.

  • If one or more key field names are assigned to the KeyFieldNames property in the cases described above, the data controller uses the bound dataset’s Locate method. If no key fields are specified, the dataset’s MoveBy method is used instead. So, the performance of all the related data operations strongly depends on the method implementation and may vary with each particular dataset type. Generally, the MoveBy method works faster than Locate with in-memory datasets, when a record to be activated is already stored in memory. With all other dataset types, the Locate method significantly outperforms MoveBy, especially when the display order of records is modified from that in the dataset by sorting, grouping, and/or filtering.

  • To improve performance with the Locate method, we recommend that you avoid using compound keys and use simple keys instead (assign only one key field name to the KeyFieldNames property). Simple keys are preferable not only for DBMS reasons, but also for key value management implementations. These implementations pass compound key values as an array of Variants, and managing it may significantly hinder performance. For instance, string key values in this array are managed as wide strings (OleStr objects), which are not as fast as normal strings (AnsiString or string).

See Also