Search code examples
delphidelphi-7delphi-2010delphi-2009dbgrid

Delphi DbGrid order by ID


Am showing data from database in DBGrid and in my Command text. I want to display data in ascending but all time is descending i dont know whay.

In command text in Client DataSet i set: SELECT * FROM groups ORDER BY ID ASC but when i compaile and grid is showed list is again start from ID=3.

enter image description here

What i do wrong


Solution

  • Do you set a value in the IndexFieldName property of your Dataset ?.

    This would override any order in your commandtext, because no matter in which order you retrieve the data, your data will posteriorly be locally ordered as your IndexName or IndexFieldName defines.