4

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.

Community
  • 1
  • 1
UnDiUdin
  • 14,924
  • 39
  • 151
  • 249
  • 1
    From the blurb: "TMemDataset is a unique fully indexable memory table that work like a regular TTable except the records and indexes are all stored in RAM. [snip] Sorting the table is as easy as doing tbMem.OrderBy := 'Fld1;Fld2';" So that looks like your solution – Jan Doggen Jan 08 '13 at 11:03
  • 2
    I dont know aboout the component you are referring but for ADO you can use ADOQuery1.Sort := 'LastName ASC, DateDue DESC' – Bharat Jan 08 '13 at 11:26
  • There is some misunderstanding because of me: TMemDataSet is a DevArt Class derived from TDataSet, while the one you mention is a 3rd part component that has the feature I need: http://www.shareit.com/product.html?productid=102196&language=FR&affiliateid=200067214 – UnDiUdin Jan 08 '13 at 11:35
  • Uh, anyway by digging i found the INdexFieldNames property that does what I need. – UnDiUdin Jan 08 '13 at 11:51

1 Answers1

9

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
UnDiUdin
  • 14,924
  • 39
  • 151
  • 249