CDS Ordering (D7)


2005-02-07 09:47:28 AM
delphi29
When opeining a TClientDataSet and specifying an index, the data is not
being read in the expected order. My code is:
RS := TClientDataSet.Create(NIL);
With RS Do
Begin
LoadFromFile(getMemoryStickFolder + 'GEIST_RESULT.CDS');
Active := False;
Filter := '(SetID=' + IntToStr(SetID) + ') AND
(ReportingPeriodID=' + IntToStr(RP) + ')';
Filtered := True;
IndexFieldNames := 'Surname;FirstName';
Active := True;
If BOF And EOF Then
GridNoData
Else
Begin
First;
While Not EOF Do
Begin
do stuff
Next
End
End;
Active := False
End;
FreeAndNil(RS);
I expect the data to be in ascending Surname and FirstName order, but it
appears to be random. Am I doing something wrong?
Also, assuming that we can get this working correctly, is there a way of
specifying a descending sort order for one or more fields?
Kind regards
Paul