線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:1386
推到 Plurk!
推到 Facebook!

指定TADODataSet.IndexFieldNames的值引发异常

答題得分者是:Fishman
lovelypp
初階會員


發表:122
回覆:111
積分:46
註冊:2003-02-19

發送簡訊給我
#1 引用回覆 回覆 發表時間:2004-03-09 09:31:29 IP:218.104.xxx.xxx 未訂閱
目的是想根据该字段排序, dset.IndexFieldNames := 'Name ASC'; <----异常: 'dset Index 'Name ASC' not found 指定dset.Sort := 'Name ASC'同样的错位 怎么办呢?
Fishman
尊榮會員


發表:120
回覆:1949
積分:2163
註冊:2006-10-28

發送簡訊給我
#2 引用回覆 回覆 發表時間:2004-03-09 14:56:04 IP:210.65.xxx.xxx 未訂閱
Hi lovelypp,    dset.IndexFieldNames := 'Name' 就好,不要加 ASCDESC ---------------------------------- 小弟才疏學淺,若有謬誤尚請不吝指教 ----------------------------------
------
Fishman
lovelypp
初階會員


發表:122
回覆:111
積分:46
註冊:2003-02-19

發送簡訊給我
#3 引用回覆 回覆 發表時間:2004-03-09 15:03:50 IP:218.104.xxx.xxx 未訂閱
老大真牛人啊,果然可以啊 但若不能加ASC 或 DESC,如何能够逆向排序?
Fishman
尊榮會員


發表:120
回覆:1949
積分:2163
註冊:2006-10-28

發送簡訊給我
#4 引用回覆 回覆 發表時間:2004-03-09 15:16:15 IP:210.65.xxx.xxx 未訂閱
Hi lovelypp,    dset.Sort := 'Name DESC'; 關於 ADODataSet 的 Sort 屬性,Help 說明如下(In D7):
Specifies the sort order of the recordset.    Delphi syntax:    property Sort: WideString;    C   syntax:    __property WideString Sort = {read=GetSort, write=SetSort};    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'
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.
因此理論上,你的寫法 dset.Sort := 'Name ASC' 應該是正確的 ---------------------------------- 小弟才疏學淺,若有謬誤尚請不吝指教 ----------------------------------
------
Fishman
系統時間:2024-03-29 2:46:47
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!