RAD Studio
ContentsIndex
PreviousUpNext
Obtaining Information About Indexes

Your application can obtain information about server-defined indexes from all table type datasets. To obtain a list of available indexes for the dataset, call the GetIndexNames method. GetIndexNames fills a string list with valid index names. For example, the following code fills a listbox with the names of all indexes defined for the CustomersTable dataset:

CustomersTable.GetIndexNames(ListBox1.Items);

 

CustomersTable->GetIndexNames(ListBox1->Items);

Note: For Paradox tables, the primary index is unnamed, and is therefore not returned by GetIndexNames. You can still change the index back to a primary index on a Paradox table after using an alternative index, however, by setting the IndexName property to a blank string.
To obtain information about the fields of the current index, use the
  • IndexFieldCount property, to determine the number of columns in the index.
  • IndexFields property, to examine a list the field components for the columns that comprise the index.
The following code illustrates how you might use IndexFieldCount and IndexFields to iterate through a list of column names in an application:

var
  I: Integer;
  ListOfIndexFields: array[0 to 20} of string;
begin
with CustomersTable do
  begin
  for I := 0 to IndexFieldCount - 1 do
     ListOfIndexFields[I] := IndexFields[I].FieldName;
  end;
end;

 

AnsiString ListOfIndexFields[20];
for (int i = 0; i < CustomersTable->IndexFieldCount; i++)
  ListOfIndexFields[i] = CustomersTable->IndexFields[i]->FieldName;

Note: IndexFieldCount is not valid for a dBASE table opened on an expression index.

Specifying an Index with IndexName 

Creating an Index with IndexFieldNames 

GetIndexNames 

GetIndexNames 

GetIndexNames 

GetIndexNames 

GetIndexNames 

GetIndexNames 

GetIndexNames

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!