[轉貼]ADO如何在程式結束前判斷是否有存檔

有關Delphi 的語法, 程式, 等
回覆文章
頭像
tim
文章: 1380
註冊時間: 2008年 11月 26日, 00:49

[轉貼]ADO如何在程式結束前判斷是否有存檔

文章 tim »

使用 ado 的 ltBatchOptimistic locktype 時, 是以 batch 的方式進行資料庫的異動處理的, 但麻煩的是要如何來判定資料是否已寫入資料庫了呢, 這時就要用 fgPendingRecords 這種 filter group 屬性來找出所有尚未寫入資料庫的資料!

轉貼自: http://delphi.ktop.com.tw/topic.asp?TOPIC_ID=41577

BatchUpdate 模式下ADO資料集FilterGroup含有以下特性:fgUnassigned,fgNone,fgPendingRecords,fgAffectedRecords,fgFetchedRecords,fgPredicate,fgConflictingRecords.

fgPendingRecords : 只顯示被異動過但尚未被更新回資料來源的資料
或是被異動過但尚未被取消更新的資料.
例:

代碼: 選擇全部

procedure Tform1.RadioButton1Click(Sender: TObject);
 begin
   if (datamodule2.ADODataSet1.LockType = ltBatchOptimistic) then
     begin
       datamodule2.ADODataSet1.Filtered := true;
       datamodule2.ADODataSet1.FilterGroup := fgPendingRecords;
     end;
 end;
end;
多多留言, 整理文章, 把經驗累積下來.....
回覆文章