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

修改存檔指令

尚未結案
rita880
一般會員


發表:38
回覆:27
積分:13
註冊:2003-04-15

發送簡訊給我
#1 引用回覆 回覆 發表時間:2003-10-08 17:26:24 IP:61.221.xxx.xxx 未訂閱
請問 : 我使用updateSQL對table做更新的動作, 若我的維護檔是 master-detail 的形式, 在修改完後, 下存檔動作時, 指令要如何寫呢? tks
cashxin2002
版主


發表:231
回覆:2555
積分:1937
註冊:2003-03-28

發送簡訊給我
#2 引用回覆 回覆 發表時間:2003-10-08 17:58:51 IP:63.84.xxx.xxx 未訂閱
您好!    
procedure TForm1.ApplyButtonClick(Sender: TObject);
begin
  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;
end;
以上供您參考, 另外, 小弟之前有篇TUpdateSQL元件之提問, timhuang前輩為小弟解答, 連接中下: http://delphi.ktop.com.tw/topic.php?TOPIC_ID=29722 參考看看! ===================== 努力,相信會獲得美麗! 忻晟
------
忻晟
rita880
一般會員


發表:38
回覆:27
積分:13
註冊:2003-04-15

發送簡訊給我
#3 引用回覆 回覆 發表時間:2003-10-08 21:55:56 IP:61.219.xxx.xxx 未訂閱
引言: 您好!
procedure TForm1.ApplyButtonClick(Sender: TObject);
begin
  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;
end;
以上供您參考, 另外, 小弟之前有篇TUpdateSQL元件之提問, timhuang前輩為小弟解答, 連接中下: http://delphi.ktop.com.tw/topic.php?TOPIC_ID=29722 參考看看! ===================== 努力,相信會獲得美麗! 忻晟
detail 檔案是多筆的, 也是直接下update的指令, 不須使用迴圈一筆一筆的 update嗎? (補充detail並未設唯一鍵的狀況下)
系統時間:2024-05-06 15:08:01
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!