我使用clientdataset在前台构成一个结果集。
但我现在想按照某一字段倒序排序。我知道可以用IndexFieldNames属性设置索引字段。
但这样是升序排序。急。怎么实现倒序排序啊。注:用的是clientdataset控件,不要叫我换控件啊。
结果集是在前台通过很多运算构成的,不要叫我在SQL语中用ORDER BY 语句哈!

解决方案 »

  1.   

    升序
    procedure TForm1.IndexAec(DataSets:TClientdataset;FieldName: String);
    begin
      DataSets.IndexName:='';
      DataSets.IndexDefs.Update;
       DataSets.AddIndex(FieldName,FieldName,[ixCaseInsensitive],'',FieldName,0);
      DataSets.IndexName:=FieldName;
      DataSets.IndexDefs.Update;
    end;
      

  2.   

    但小弟英文实在太差。楼上老大能否解释一下下面各个参数的涵义。
    Value DescriptionixPrimary The index is the primary index of the table. (Not applicable to dBASE tables).
    ixUnique Each value in the index is unique; there are no duplicates. (Not applicable to all table types.)
    ixDescending The index imposes a descending sort order. (Not applicable to all table types.)
    ixExpression The index is based on a dBASE key expression. (Only applicable to dBASE tables).
    ixCaseInsensitive The index sorts records case insensitively. (Not applicable to all table types.)ixNonMaintained The index is not automatically updated when the data is edited. (Not applicable to all table types.)Warning: Attempting to create an index using options that are not applicable to the table type causes AddIndex to raise an exception.See the vendor-supplied documentation for the particular database system for details on what index options are applicable.
      

  3.   

    ixDescending The index imposes a descending sort order. (Not applicable to all table types.)
    -----------------
    ixDescending      此索引指定倒序排序.(不是對所有的表類型都適用.)