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

請問有關 DataSetProvider->BeforeUpdateRecord 用法

答題得分者是:GrandRURU
herbert2
尊榮會員


發表:58
回覆:640
積分:894
註冊:2004-04-16

發送簡訊給我
#1 引用回覆 回覆 發表時間:2008-11-06 19:43:23 IP:211.72.xxx.xxx 訂閱
SQLConnection
| ↖____________________
| ↖
SQLQuery ->SQLConnection = ‧
| ↖____________________
| ↖
DataSetProvider->DataSet = ‧
| ↖____________________
| ↖
ClientDataSet ->ProviderName = ‧
| ↖____________________
| ↖
DataSource ->DataSet = ‧
| ↖____________________
| ↖
DBGrid,DBNavigator->DataSource = ‧

DataSetProvider1BeforeUpdateRecord(TObject *Sender, TDataSet *SourceDS,
TCustomClientDataSet *DeltaDS, TUpdateKind UpdateKind, bool &Applied)


DataSetProvider 的 Published Property 只有一個 DataSet, 故
SourceDS 是指那個 DataSet ? 或是本 ClientDataSet 或 SQLQuery 之 Old Value 嗎?
DeltaDS 又是指那個 DataSet ? 或是本 ClientDataSet 或 SQLQuery 之 New Value 嗎?


UpdateKind 有 ukModify、ukInsert、ukDelete
則是否 ClientDataSet->BeforePost() 或 BeforeDelete() 後便接著進入此 Event ?


若 DataSet 來源是 SELECT * FROM MyMultiTableView WHERE ‧‧‧‧
則在此 Event 直接寫 Code 呼叫 SQLConnect->Excute() 去 Update 或 Delete
在 Server 中的多個 Table, 若無 Error 便設 Applied = true
則相關 Component 便不會再送 DaltaDS 的資料到 Server 端嗎?


因一向使用 BDE TQuery 而未曾使用過 ClientDataSet 與 DataSetProvider,
請諸位先進不吝指教一下!
因測試環境尚未就緒, 只先從文件閱讀, 尚祈包涵!

本提問原誤置於 http://delphi.ktop.com.tw/board.php?cid=168&fid=1499&tid=95900 尚請版本刪除!

編輯記錄
herbert2 重新編輯於 2008-11-06 19:51:01, 註解 無‧
herbert2 重新編輯於 2008-11-06 19:52:30, 註解 無‧
GrandRURU
站務副站長


發表:240
回覆:1680
積分:1874
註冊:2005-06-21

發送簡訊給我
#2 引用回覆 回覆 發表時間:2008-11-06 23:40:01 IP:220.139.xxx.xxx 未訂閱
你可以參考這篇對岸同好寫的文章
http://www.poptool.net/server/p49/J495981.shtml


===================引 用 herbert2 文 章===================
43...

DataSetProvider1BeforeUpdateRecord(TObject *Sender, TDataSet *SourceDS,
TCustomClientDataSet *DeltaDS, TUpdateKind UpdateKind, bool &Applied)


DataSetProvider 的 Published Property 只有一個 DataSet, 故
SourceDS 是指那個 DataSet ? 或是本 ClientDataSet 或 SQLQuery 之 Old Value 嗎?
DeltaDS 又是指那個 DataSet ? 或是本 ClientDataSet 或 SQLQuery 之 New Value 嗎?


UpdateKind 有 ukModify、ukInsert、ukDelete
則是否 ClientDataSet->BeforePost() 或 BeforeDelete() 後便接著進入此 Event ?

應該是AfterPost/Delete之後

若 DataSet 來源是 SELECT * FROM MyMultiTableView WHERE ‧‧‧‧
則在此 Event 直接寫 Code 呼叫 SQLConnect->Excute() 去 Update 或 Delete
在 Server 中的多個 Table, 若無 Error 便設 Applied = true
則相關 Component 便不會再送 DaltaDS 的資料到 Server 端嗎?

43...

herbert2
尊榮會員


發表:58
回覆:640
積分:894
註冊:2004-04-16

發送簡訊給我
#3 引用回覆 回覆 發表時間:2008-11-07 07:03:53 IP:211.72.xxx.xxx 訂閱
謝謝 GrandRURU 兄提供的資訊, 已收納.
我也有找到其他幾篇文章, 近日先研讀一下.
再次謝謝!
GrandRURU
站務副站長


發表:240
回覆:1680
積分:1874
註冊:2005-06-21

發送簡訊給我
#4 引用回覆 回覆 發表時間:2010-11-09 16:52:52 IP:203.75.xxx.xxx 未訂閱
原始網頁不在了,當初應該轉貼原文過來,過錯過錯

把help貼上來好了 (被打)
宣告函式:
[code cpp]
typedef void __fastcall (__closure *TBeforeUpdateRecordEvent)(TObject* Sender, TDataSet SourceDS, TCustomClientDataSet DeltaDS, Db::TUpdateKind UpdateKind, bool &Applied);
[/code]

The Sender parameter identifies the provider that is applying updates.
Sender參數指向一個正在進行套用更新狀態的提供者。(在這邊指的是繼承TBaseProvider的相關類別)

The SourceDS parameter is the dataset from which the data originated. If there is no source dataset, this value is NULL. The source dataset may not be active when the event occurs, so set its Active property to true before trying to access its data.
SourceDS參數是初始的DataSet,如果沒有來源資料集,此項目會是NULL。
本事件觸發時SourceDS可能仍在close狀態,所以要先把SourceDS打開。

The DeltaDS parameter is a client dataset containing all the updates that are being applied. The current record represents the update that is about to be applied.
DeltaDS參數包含了該資料集所有更新前和更新後的資料

The UpdateKind parameter indicates whether this update is the modification of an existing record (ukModify), a new record to insert (ukInsert), or an existing record to delete (ukDelete).
UpdateKind參數標示觸發事件的變更項:更新現有資料(ukModify), 新增記錄(ukInsert)或是刪除現有資料(ukDelete)

The Applied parameter controls what happens after exiting the event handler. If the event handler sets Applied to true, the provider ignores the update: it neither tries to apply it, nor does it log an error indicating that the update was not applied. If the event handler leaves Applied as false, the provider tries to apply the update after the event handler exits.
Applied參數是指發生在離開事件之後的控制。假如設定為true, Provider會將忽略更新:不套用,也不做例外處理和error log記錄(如果有的話);如果為false,則Provider會在離開該事件後再嘗試進行套用更新的工作。
編輯記錄
GrandRURU 重新編輯於 2010-11-09 03:02:45, 註解 無‧
系統時間:2024-04-25 18:24:46
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!