Sorting TMSQuery

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
FaNIX
Posts: 6
Joined: Sat 19 Jan 2008 13:22
Location: pretoria

Sorting TMSQuery

Post by FaNIX » Thu 14 Feb 2008 11:44

Hi,

How do one sort with the TMSQuery object, because TADOQuery has a Sort property, but I see that the TMSQuery does now. Please explain...

Thanks.

FaNIX
Posts: 6
Joined: Sat 19 Jan 2008 13:22
Location: pretoria

Post by FaNIX » Thu 14 Feb 2008 12:14

Read on the forum, and got it working:

Code: Select all

procedure Sort_Grid(ACol : Integer; var ASortBy : String; var ADataset : TMSQuery);
var
  fldName : String;
begin

  if ASortBy = 'ASC' then
    ASortBy := 'DESC'
  else
    ASortBy := 'ASC';

  fldName := ADataset.FieldList.fields[ACol].FieldName;

  ADataset.IndexFieldNames := fldName +' '+ ASortBy +';';

end;

Post Reply