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

判斷數據集狀態的小問題。

答題得分者是:Justmade
yezi_ji
一般會員


發表:16
回覆:31
積分:9
註冊:2003-03-22

發送簡訊給我
#1 引用回覆 回覆 發表時間:2003-03-29 18:02:54 IP:218.14.xxx.xxx 未訂閱
請教各位大哥及前輩,小弟有一問題。如下: if DateSource1.Dateset.State in [dsEdit,dsInsert] then . . . 小弟想判斷數據集的狀態,請問:在in後括號里應怎麽寫,也就是dsEdit和dsInsert應用什麽代替?我還想知道數據集的全部狀態。謝謝! 我是菜鳥,請多指點! 不勝感激!!
Justmade
版主


發表:94
回覆:1934
積分:2030
註冊:2003-03-12

發送簡訊給我
#2 引用回覆 回覆 發表時間:2003-03-29 18:25:05 IP:218.16.xxx.xxx 未訂閱
in [xxx,yyy,zzz] 就即是 xxx yyy zzz 中的其中之一均可 數據集狀態最當使用的主要有 dsEdit, dsInsert 及 dsBrowse。 由於數據集只有在 dsEdit 及 dsInsert 情怳下才可修改資料,所以很經常會用到 : if not (DataSet.State in [dsEdit, dsInsert]) then DataSet.Edit; 意思即是說如果數據集不在修改或插入狀態,就將狀態變為插入狀態。 全部狀態 Help 裡有丫,不過大都不會用到 dsInactive Dataset is closed, so its data is unavailable. 數據集未開,沒有狀態 dsBrowse Data can be viewed, but not changed. This is the default state of an open dataset. 最一般溜覽中的狀態 dsEdit Active record can be modified. 修改中的狀態 dsInsert The active record is a newly inserted buffer that has not been posted. This record can be modified and then either posted or discarded. 新增記錄中的狀態 dsSetKey TTable and TClientDataSet only. Record searching is enabled, or a SetRange operation is under way. A restricted set of data can be viewed, and no data can be edited or inserted. 使用 SetKey / SetRange 搜尋中的狀態 dsCalcFields An OnCalcFields event is in progress. Noncalculated fields cannot be edited, and new records cannot be inserted. 在計算連算欄位中,正式欄位不能更改亦不能新增記錄 dsFilter An OnFilterRecord event is in progress. A restricted set of data can be viewed. No data can edited or inserted. 正在計算 Filter 結果中。 dsNewValue Temporary state used internally when a field components NewValue property is accessed. dsOldValue Temporary state used internally when a field components OldValue property is accessed. dsCurValue Temporary state used internally when a field components CurValue property is accessed. dsBlockRead Data-aware controls are not updated and events are not triggered when moving to the next record. dsInternalCalc Temporary state used internally when values need to be calculated for a field that has a FieldKind of fkInternalCalc. dsOpening DataSet is in the process of opening but has not finished. This state occurs when the dataset is opened for asynchronous fetching.
yezi_ji
一般會員


發表:16
回覆:31
積分:9
註冊:2003-03-22

發送簡訊給我
#3 引用回覆 回覆 發表時間:2003-03-29 18:37:49 IP:218.14.xxx.xxx 未訂閱
if DateSource1.Dateset.State in [dsInsert,dsEdit] then 不好意思,對上面的語句在編譯時報錯,為: [Error] fmSimple.pas(43): Undeclared identifier: 'dsInsert' [Error] fmSimple.pas(43): Incompatible types: 'TDataSetState' and 'Integer' 想問下是怎麽回事? 我是菜鳥,請多指點! 不勝感激!!
Justmade
版主


發表:94
回覆:1934
積分:2030
註冊:2003-03-12

發送簡訊給我
#4 引用回覆 回覆 發表時間:2003-03-29 18:44:22 IP:218.16.xxx.xxx 未訂閱
你要在該使用這語法的 unit use DB 才可以
yezi_ji
一般會員


發表:16
回覆:31
積分:9
註冊:2003-03-22

發送簡訊給我
#5 引用回覆 回覆 發表時間:2003-03-29 18:46:19 IP:218.14.xxx.xxx 未訂閱
非常感謝你。 我是菜鳥,請多指點! 不勝感激!!
Justmade
版主


發表:94
回覆:1934
積分:2030
註冊:2003-03-12

發送簡訊給我
#6 引用回覆 回覆 發表時間:2003-03-29 18:56:00 IP:218.16.xxx.xxx 未訂閱
通當出現 undeclared identifier 'xxxx' 都是因為你沒 use 其中一個Delphi 的 Unit, 那甚樣找是那個 Unit 呢?最好在 Help 找。 如今次你可 1. 選定你的 Table 或 Query 元件 2. 按 F1 3. 按 Properties 4. 找出並 按 State (在 Derived from TDataSet) 5. 看看內容 property State: TDataSetState; 按 TDataSetState 6. 找到 TDataSetState 是屬於 Unit DB 的,便在你的 Form 加入 Use DB 便可。
系統時間:2024-07-04 0:16:07
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!