Adding a New Index
Go Up to Sorting and Indexing
There are three ways to add indexes to a client dataset:
Methods | Description |
---|---|
Use the IndexFieldNames property |
To create a temporary index at run time that sorts the records in the client dataset, you can use the IndexFieldNames property. Specify field names, separated by semicolons. Ordering of field names in the list determines their order in the index. This is the least powerful method of adding indexes. You can't specify a descending or case-insensitive index, and the resulting indexes do not support grouping. These indexes do not persist when you close the dataset, and are not saved when you save the client dataset to a file. |
Call AddIndex |
To create an index at run time that can be used for grouping, call AddIndex. AddIndex lets you specify the properties of the index, including:
Indexes created with AddIndex do not persist when the client dataset is closed. (That is, they are lost when you reopen the client dataset). You cannot call AddIndex when the dataset is closed. Indexes you add using AddIndex are not saved when you save the client dataset to a file. |
Use the IndexDefs property |
The third way to create an index is at the time the client dataset is created. Before creating the client dataset, specify the desired indexes using the IndexDefs property. The indexes are then created along with the underlying dataset when you call CreateDataSet. See Creating and deleting tables for more information about creating client datasets. As with AddIndex, indexes you create with the dataset support grouping can sort in ascending order on some fields and descending order on others, and can be case-insensitive on some fields and case-sensitive on others. |
Tip: You can index and sort on internally calculated fields with client datasets.