DelphiFAQ Home Search:
General :: Programming :: Delphi :: Database
Database development with Delphi. Includes issues with BDE, ADO and InterBase.

Articles:

This list is sorted by recent document popularity (not total page views).
New documents will first appear at the bottom.

Only the 40 most recently viewed articles are shown.
You can see the full list here.

Featured Article

Create an index for a TClientDataSet at runtime

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;
     // Define the fields
     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);
     // Define the index
     IndexDefs.Clear;
     IndexDefs.Add ('IProject', 'Project;Module;FuncName',
                    [ixPrimary, ixUnique]);
     // this seems not to do anything
     IndexName := 'IProject';
 	
     // this does work
     IndexFieldNames := 'Project;Module;FuncName';
 	
     // Create the dataset
     CreateDataSet;
     Open;
   End { with ClientDataSet1 }
 

Generated 16:01:22 on Sep 23, 2018