Delphi .NET (2) Database (71) Delphi IDE (90) Network (39) Printing (3) Strings (12) VCL (83) Windows with Delphi (280)
Exchange Links About this site Links to us 
|
Create an index for a TClientDataSet at runtime
1 comments. Current rating: (1 votes). Leave comments and/ or rate it.
When I had to create an index for a in-memory table, I got the
error message 'No active index' when accessing the index e.g. with FindKey().
I had originally created the index with the property IndexName
and finally found out that this did not select my index.
Selecting the index by the property IndexFieldNames worked fine,
as the following source shows.
This is also an example how to create a memory table..
 | |  | |
With ClientDataSet1 Do
Begin
Close;
FieldDefs.Clear;
FieldDefs.Add ('Project', ftInteger, 0, True);
FieldDefs.Add ('Module', ftString, 60, False);
FieldDefs.Add ('FuncName',ftString, 60, False);
FieldDefs.Add ('FuncDate',ftDate, 0, False);
FieldDefs.Add ('FuncCRC', ftString, 2, False);
FieldDefs.Add ('Programmer', ftString, 32, False);
IndexDefs.Clear;
IndexDefs.Add ('IProject', 'Project;Module;FuncName',
[ixPrimary, ixUnique]);
IndexName := 'IProject';
IndexFieldNames := 'Project;Module;FuncName';
CreateDataSet;
Open;
End { with ClientDataSet1 }
| |  | |  |
Comments:
|