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

TClientDataSet: Temporary vs. permanent indices

On TClientDataSets, that are not connected to a provider but loaded as local text files,
('thin client in brief-case mode'), you cannot use TQuerys.
You may use the .Filter property to select data and use an index to sort.

This sample code shows how to create a temporary index (not saved by SaveToFile())
and how to create a permanent index (saved by SaveToFile()):

With ClientDataSet1 Do
 Begin
   Close;
   // Define the fields
   FieldDefs.Clear;
   FieldDefs.Add ('Project', ftInteger, 0, True);
   FieldDefs.Add ('Number', ftInteger, 0, False);
   // [..]
   // Define the PERMANENT index - it is saved with SaveToFile()
   IndexDefs.Clear;
   IndexDefs.Add ('IProject', 'Project', [ixPrimary, ixUnique]);
   // Create the dataset
   CreateDataSet;
   Open;
   // the following temporary index is not saved
   // with data when using SaveToFile()
   AddIndex('TempIndex', 'Number;Project', [ixPrimary, ixUnique]);
 End { with ClientDataSet1 }
 
You don't like the formatting? Check out SourceCoder then!
Generated 0:01:14 on Jun 21, 2018