> SetComplete 要寫在哪裡?
 
元件不會在 SetComplete 之後"立即"停止運作(deactivate),而是當
控制權回到 MTS/COM+ 執行環境時,元件才停止運作。所以下面兩種寫法
都是可能被採用的:
 
function TCustomer.GetName: widestring;
begin
  try
    Result := 'Michael';
    SetComplete;
  except
    SetAbort;
    raise;
  end;
end;
 
function TCustomer.GetName: widestring;
begin
  SetComplete;
  try
    Result := 'Michael';
  except
    SetAbort;
    raise;    
  end;
end;
 
如果是交易性質的元件,那麼 SetComplete 同時也告訴 MTS/COM+:「我
這邊負責的交易動作沒問題。」
請注意並不是在控制權回到 MTS/COM+ 時就立刻 commit,而是等到所有
加入這次交易的元件都表示"沒問題",各個元件處理的異動資料才會真正
寫入資料庫中。

另外,SetComplete 不可寫在元件的 Activate 及 Deactivate 方法中,
這樣會造成元件無法 abort 交易。

    Source: geocities.com/huanlin_tsai/faq

               ( geocities.com/huanlin_tsai)