applyupdates和updatebatch二者有什麼不同 |
尚未結案
|
sundy6719
初階會員 ![]() ![]() 發表:136 回覆:78 積分:42 註冊:2002-07-10 發送簡訊給我 |
|
hahalin
版主 ![]() ![]() ![]() ![]() ![]() ![]() 發表:295 回覆:1698 積分:823 註冊:2002-04-14 發送簡訊給我 |
|
yachanga
資深會員 ![]() ![]() ![]() ![]() ![]() 發表:24 回覆:335 積分:296 註冊:2003-09-27 發送簡訊給我 |
Hi sundy6719您好:
以下是小弟淺見..
ApplyUpdates 和 UpdateBatch 目的功能相同, 都是將cached data 一次寫回資料庫中..
最主要的不同是資料存取技術與使用對象不同, Borland 開發的BDE技術 系列使用ApplyUpdate, 而M$ ADO技術使用UpdateBatch.. 不知道您使用哪種資料存取技術呢??
若您使用BDE, 則您只能用ApplyUpdate...
如果您使用ADO, 則您只能用UpdateBatch..
BDE 範例 with CustomerQuery do begin Database1.StartTransaction; try ApplyUpdates; {try to write the updates to the database}; Database1.Commit; {on success, commit the changes}; except Database1.Rollback; {on failure, undo the changes}; raise; {raise the exception to prevent a call to CommitUpdates!} end; CommitUpdates; {on success, clear the cache} end; ADO 範例 procedure TForm1.Button1Click(Sender: TObject); begin ADODataSet1.LockType := ltBatchOptimistic; ADODataSet1.open; end; procedure TForm1.SpeedButton2Click(Sender: TObject); begin ADOConnection1.BeginTrans; try ADODataSet1.UpdateBatch; ADOConnection1.CommitTrans; except ADOConnection1.RollbackTrans; end; end; end;~悠遊法國號~ |
Ktop_Robot
站務副站長 ![]() ![]() 發表:0 回覆:3511 積分:0 註冊:2007-04-17 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |