关于TABLE组件的排序问题 ( 积分: 100 )

  • 主题发起人 主题发起人 tonye_m
  • 开始时间 开始时间
T

tonye_m

Unregistered / Unconfirmed
GUEST, unregistred user!
我几年前写的一个小程序用的.DB的数据库和TABLE组件 ,在查询送货明细报表时按日期查询出来是没有问题;但是我想查询出来的报表按商品名称排序,就是说A商品名称从上到下在一起,然后B商品从上到下一起;急啊,请各位高手帮忙,感谢!
 
我几年前写的一个小程序用的.DB的数据库和TABLE组件 ,在查询送货明细报表时按日期查询出来是没有问题;但是我想查询出来的报表按商品名称排序,就是说A商品名称从上到下在一起,然后B商品从上到下一起;急啊,请各位高手帮忙,感谢!
 
如果你已为“商品名称”字段建了索引,则可用Table.IndexFieldNames := '商品名称' 来排序;
其实最好是用Query,它的SQL语句里可用 order by 商品名称 来排序,很方便。
 
Specifies the sort order of the recordset.
property Sort: WideString;
Description
Set Sort to establish or change the list of fields on which the recordset is sorted. Set sort to the name of a single field or to a comma-separated list of fields. Each field may optionally be followed by the keyword ASCENDING or DESCENDING to specify a sort direction for the field. If one of these keywords is not used, the default sort direction for the field is ascending. Set Sort to an empty string to reset the recordset to the sort order originally used when the recordset抯 data was first retrieved.
ADOQuery1.Sort := 'LastName ASC, DateDue DESC'
Read Sort to determine the field (or fields) on which the recordset is sorted.
Note: If the cursor is client-side (the dataset component抯 CursorLocation property or that of an associated TADOConnection component is clUseClient) and no index already exists matching the requested field sort order, a temporary index is created. Resetting the sort order by setting Sort to an empty string automatically deletes the temporary index.
 
后退
顶部