全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:1706
推到 Plurk!
推到 Facebook!

請教如何直接指定tadodataset的filter屬性?

尚未結案
huangeider
高階會員


發表:288
回覆:492
積分:231
註冊:2003-02-26

發送簡訊給我
#1 引用回覆 回覆 發表時間:2003-11-23 10:31:13 IP:61.231.xxx.xxx 未訂閱
在tadodataset中程式指定filter屬性如下,但小弟不想用程式來指定filter 篩選條件值,請教如下方程式中的條件值,直接在tadodataset中的filter中輸入 該如何做?
begin
  try
    adodataset1.Filtered:=false;
    adodataset1.Filter:='country= ' #39 scity #39;
  finally
  adodataset1.Filtered:=true;
  end;
end;
「堅持」從洗馬桶做起 Aric
mustapha.wang
資深會員


發表:89
回覆:409
積分:274
註冊:2002-03-13

發送簡訊給我
#2 引用回覆 回覆 發表時間:2003-11-25 15:10:43 IP:218.1.xxx.xxx 未訂閱
要输入scity变量?太刁,要看看delphi9能否办到。     久病成良医--多试 千人之诺诺,不如一士之谔谔--兼听
------
江上何人初见月,江月何年初照人
chih
版主


發表:48
回覆:1186
積分:639
註冊:2002-04-02

發送簡訊給我
#3 引用回覆 回覆 發表時間:2003-11-26 18:22:32 IP:218.164.xxx.xxx 未訂閱
begin
  ADODataSet1.Close;
  try
    ADODataSet1.Filtered := false;
    ADODataSet1.Filter := 'country= '   #39   scity   #39;
  finally
    ADODataSet1.Filtered := true;
  end;
  ADODataSet1.Open;
end;
另外請確認scity為string型態,且不為空值..TRY TRY SEE
發表人 - chih 於 2003/11/26 18:26:19
mustapha.wang
資深會員


發表:89
回覆:409
積分:274
註冊:2002-03-13

發送簡訊給我
#4 引用回覆 回覆 發表時間:2003-11-26 20:17:43 IP:218.1.xxx.xxx 未訂閱
喂,chih,顶楼的不想用程式來指定filter 想在Object Inspetor里输入 久病成良医--多试 千人之诺诺,不如一士之谔谔--兼听
------
江上何人初见月,江月何年初照人
chih
版主


發表:48
回覆:1186
積分:639
註冊:2002-04-02

發送簡訊給我
#5 引用回覆 回覆 發表時間:2003-11-26 22:49:54 IP:218.165.xxx.xxx 未訂閱
引言: 喂,chih,顶楼的不想用程式來指定filter 想在Object Inspetor里输入 久病成良医--多试 千人之诺诺,不如一士之谔谔--兼听
sorry..看錯了.. 不過既然程式就可以指定,又只有短短幾行,為何要那麼麻煩ㄋ??
hahalin
版主


發表:295
回覆:1698
積分:823
註冊:2002-04-14

發送簡訊給我
#6 引用回覆 回覆 發表時間:2003-11-26 23:00:48 IP:211.76.xxx.xxx 未訂閱
引言: 喂,chih,顶楼的不想用程式來指定filter 想在Object Inspetor里输入 久病成良医--多试 千人之诺诺,不如一士之谔谔--兼听
程式寫歸寫喔,禮貌也要有一點啊... 這種語氣自己看看, 像話嗎... cow be
huangeider
高階會員


發表:288
回覆:492
積分:231
註冊:2003-02-26

發送簡訊給我
#7 引用回覆 回覆 發表時間:2003-11-26 23:38:19 IP:218.172.xxx.xxx 未訂閱
不過既然程式就可以指定,又只有短短幾行,為何要那麼麻煩ㄋ?? 小弟只是在想Borland 把filter的屬性設在Object Inspector 應該有其深意, 到底為何呢?要怎麼用呢?想寄信去borland問但英文不靈光,abc用時方恨少,悔恨當時年紀小,回首來時路,英文忘光光,重拾舊書本,再造英文第二春..哈哈 「堅持」從洗馬桶做起
mustapha.wang
資深會員


發表:89
回覆:409
積分:274
註冊:2002-03-13

發送簡訊給我
#8 引用回覆 回覆 發表時間:2003-11-27 09:00:04 IP:218.1.xxx.xxx 未訂閱
to hahalin: 我并非无理哟,这像一堆人坐在一张桌子前讨论问题,huangeider提出问题,chih误解了,我马上提醒chih他他误解了,有何无理? 而“喂”这个词,在我们,是对朋友/爱人都可以用的,很随便,难道在对面会有歧义?     久病成良医--多试 千人之诺诺,不如一士之谔谔--兼听
------
江上何人初见月,江月何年初照人
chih
版主


發表:48
回覆:1186
積分:639
註冊:2002-04-02

發送簡訊給我
#9 引用回覆 回覆 發表時間:2003-11-27 12:14:02 IP:218.164.xxx.xxx 未訂閱
節錄Filter From HELP.. Specifies the text of the current filter for a recordset. property Filter: String; Description Use Filter to specify a recordset filter. When filtering is applied to a recordset by setting the Filtered property to True, only those records that meet a filters conditions are available to the application. Filter contains the expression used to evaluate the rows in the recordset. At design-time, enter the filter expression into the editing cell for the Filter property within the Object Inspector. At runtime, assign astring containing the filter expression to the Filter property. The filter expression below displays only those rows where the State field is "CA" or "MA": State = 'CA' OR State = 'MA' The following runtime example shows how to assign that filter expression to the Filter property and activate the filtering. with ADODataSet1 do begin Filtered := False; Filter := 'State = ' QuotedStr('CA') ' OR ' 'State = ' QuotedStr('CA'); Filtered := True; end; When a filter is set, Blank records do not appear unless explicitly included in the filter. To include rows based on blank, (or "NULL") values in table columns, compare the column to NULL in the expression. For example: with ADODataSet1 do begin Filtered := False; Filter := 'State = ' QuotedStr('CA') ' OR ' 'State = NULL'; Filtered := True; end; Tip: Applications can set Filter at runtime to change the filtering condition for a dataset at (for example, in response to user input). Note: include a space between comparison values and comparison operators in filter expressions. For instance, ensure that there is a space after the field name and before the operator.
huangeider
高階會員


發表:288
回覆:492
積分:231
註冊:2003-02-26

發送簡訊給我
#10 引用回覆 回覆 發表時間:2003-11-29 17:42:06 IP:218.172.xxx.xxx 未訂閱
引言: 節錄Filter From HELP.. Specifies the text of the current filter for a recordset. property Filter: String; Description Use Filter to specify a recordset filter. When filtering is applied to a recordset by setting the Filtered property to True, only those records that meet a filters conditions are available to the application. Filter contains the expression used to evaluate the rows in the recordset. At design-time, enter the filter expression into the editing cell for the Filter property within the Object Inspector. At runtime, assign astring containing the filter expression to the Filter property. The filter expression below displays only those rows where the State field is "CA" or "MA": State = 'CA' OR State = 'MA' The following runtime example shows how to assign that filter expression to the Filter property and activate the filtering. with ADODataSet1 do begin Filtered := False; Filter := 'State = ' QuotedStr('CA') ' OR ' 'State = ' QuotedStr('CA'); Filtered := True; end; When a filter is set, Blank records do not appear unless explicitly included in the filter. To include rows based on blank, (or "NULL") values in table columns, compare the column to NULL in the expression. For example: with ADODataSet1 do begin Filtered := False; Filter := 'State = ' QuotedStr('CA') ' OR ' 'State = NULL'; Filtered := True; end; Tip: Applications can set Filter at runtime to change the filtering condition for a dataset at (for example, in response to user input). Note: include a space between comparison values and comparison operators in filter expressions. For instance, ensure that there is a space after the field name and before the operator.
以上綠色的字小弟實在看不懂意思 在Object Inspector中把filter property 輸入state='CA'也是錯的 state是否是一個自設的變數?小弟功力尚淺,挖 看 抹,!chih兄!拍洗啦! 「堅持」從洗馬桶做起 Aric
chih
版主


發表:48
回覆:1186
積分:639
註冊:2002-04-02

發送簡訊給我
#11 引用回覆 回覆 發表時間:2003-11-29 22:32:36 IP:218.165.xxx.xxx 未訂閱
引言: The filter expression below displays only those rows where the State field is "CA" or "MA": State = 'CA' OR State = 'MA' 以上綠色的字小弟實在看不懂意思 在Object Inspector中把filter property 輸入state='CA'也是錯的 state是否是一個自設的變數?小弟功力尚淺,挖 看 抹,!chih兄!拍洗啦! 「堅持」從洗馬桶做起 Aric
hi...huangeider 綠色部分是指如果你的Table欄名叫做State,你想要查詢這各State欄位裡面的值是'CA' 或 'MA'的,就照範例程式這樣下 Filter := 'State = ' QuotedStr('CA') ' OR ' 'State = ' QuotedStr('CA'); 如果你只要查詢'CA的則是這樣 Filter := 'State = ' QuotedStr('CA') ; TRY TRY SEE
huangeider
高階會員


發表:288
回覆:492
積分:231
註冊:2003-02-26

發送簡訊給我
#12 引用回覆 回覆 發表時間:2003-12-03 09:32:57 IP:218.172.xxx.xxx 未訂閱
嗯 看起來 目前似乎無法直接指定 深思... 「堅持」從洗馬桶做起 Aric
elase
一般會員


發表:4
回覆:23
積分:10
註冊:2003-06-05

發送簡訊給我
#13 引用回覆 回覆 發表時間:2003-12-03 12:09:25 IP:61.219.xxx.xxx 未訂閱
adodataset1.Filter:='country= ' #39 scity #39; 直接把下面的字串填入 filter 屬性就好了 country = 'scity'
huangeider
高階會員


發表:288
回覆:492
積分:231
註冊:2003-02-26

發送簡訊給我
#14 引用回覆 回覆 發表時間:2003-12-03 12:53:04 IP:218.172.xxx.xxx 未訂閱
引言: adodataset1.Filter:='country= ' #39 scity #39; 直接把下面的字串填入 filter 屬性就好了 country = 'scity'
感恩啊! 「堅持」從洗馬桶做起 Aric
系統時間:2024-11-23 11:15:50
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!