Sort a Delphi dataset

LaBracca picture LaBracca · Jan 8, 2013 · Viewed 9.9k times · Source

I have an unsorted dataset (a TMSQuery from Devart) that I cannot sort using ORDER BY because I manipulate the records after opening the query so the order given by "ORDER BY" is lost.

I don't want to rewrite the whole logic so I should find a way to sort a dataset.

I can Assign the dataset to a TMemDataSet (TMemDataSet is a DevArt class) descendant (TVirtualTable from Devart), but after this how do I sort (I need to sort by a date field)?

I read this question but it doesn't relly contain the answer I am looking for.

Answer

LaBracca picture LaBracca · Jan 8, 2013

Using IndexFieldNames I solved the problem, it was what I waslooking for. Directly from the TMSQuery component:

MSQuery1.IndexFieldNames := 'EXECUTION_DATE'; //this does the job