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

請教新增一筆資料進到資料庫~~

答題得分者是:Fishman
depblue
一般會員


發表:38
回覆:29
積分:13
註冊:2004-12-27

發送簡訊給我
#1 引用回覆 回覆 發表時間:2005-01-14 13:50:33 IP:211.22.xxx.xxx 未訂閱
請問: 我在新增一筆資料進入資料庫時, 有時資料可以更新進去,有時資料卻沒有更新進到資料庫, 那一筆沒更新的資料再更新一次,又可以進去了, 請問,這是什麼問題,又怎麼解決?? @@
pillar62
資深會員


發表:9
回覆:324
積分:271
註冊:2002-04-15

發送簡訊給我
#2 引用回覆 回覆 發表時間:2005-01-14 14:03:36 IP:210.64.xxx.xxx 未訂閱
hi depblue 可以詳述你的程式碼跟資料庫的細節嗎?你的問題很含糊喔!! Pillar Wang
------
Pillar Wang
depblue
一般會員


發表:38
回覆:29
積分:13
註冊:2004-12-27

發送簡訊給我
#3 引用回覆 回覆 發表時間:2005-01-14 14:23:05 IP:211.22.xxx.xxx 未訂閱
引言: 請問: 我在新增一筆資料進入資料庫時, 有時資料可以更新進去,有時資料卻沒有更新進到資料庫, 那一筆沒更新的資料再更新一次,又可以進去了, 請問,這是什麼問題,又怎麼解決?? @@
我的資料庫是使用MS SQL with stga_reQu do begin Close; SQL.Clear; SQL.Add('select * from stga_re where gano = :p_gano'); SQL.Add('and ordno = :p_ordno and stbno = :p_stbno'); Parameters.ParamByName('p_gano').Value := stga_maQuGANO.Value; Parameters.ParamByName('p_ordno').Value := stga_deQuORDNO.Value; Parameters.ParamByName('p_stbno').Value := stga_deQuSTBNO.Value; Open; end; if (m_ts > 0) or (m_twei > 0) then =>這兩個變數都不等於0 begin if stga_reQu.RecordCount = 0 then =>RecordCount也等於0 begin stga_reQu.Insert; stga_reQuGANO.Value := stga_maQuGANO.Value; stga_reQuGA_DA.Value := stga_maQuGA_DA.Value; stga_reQuORDNO.Value := stga_deQuORDNO.Value; stga_reQuSTBNO.Value := stga_deQuSTBNO.Value; stga_reQuRE_PER_S.Value := m_ts; stga_reQuRE_PER_WEI.Value := m_twei; end; end;
depblue
一般會員


發表:38
回覆:29
積分:13
註冊:2004-12-27

發送簡訊給我
#4 引用回覆 回覆 發表時間:2005-01-14 14:24:10 IP:211.22.xxx.xxx 未訂閱
引言: 請問: 我在新增一筆資料進入資料庫時, 有時資料可以更新進去,有時資料卻沒有更新進到資料庫, 那一筆沒更新的資料再更新一次,又可以進去了, 請問,這是什麼問題,又怎麼解決?? @@
我的資料庫是使用MS SQL with stga_reQu do begin Close; SQL.Clear; SQL.Add('select * from stga_re where gano = :p_gano'); SQL.Add('and ordno = :p_ordno and stbno = :p_stbno'); Parameters.ParamByName('p_gano').Value := stga_maQuGANO.Value; Parameters.ParamByName('p_ordno').Value := stga_deQuORDNO.Value; Parameters.ParamByName('p_stbno').Value := stga_deQuSTBNO.Value; Open; end; if (m_ts > 0) or (m_twei > 0) then =>這兩個變數都不等於0 begin if stga_reQu.RecordCount = 0 then =>RecordCount也等於0 begin stga_reQu.Insert; stga_reQuGANO.Value := stga_maQuGANO.Value; stga_reQuGA_DA.Value := stga_maQuGA_DA.Value; stga_reQuORDNO.Value := stga_deQuORDNO.Value; stga_reQuSTBNO.Value := stga_deQuSTBNO.Value; stga_reQuRE_PER_S.Value := m_ts; stga_reQuRE_PER_WEI.Value := m_twei; stga_reQu.UpdateBatch; end; end;
Fishman
尊榮會員


發表:120
回覆:1949
積分:2163
註冊:2006-10-28

發送簡訊給我
#5 引用回覆 回覆 發表時間:2005-01-14 14:40:49 IP:210.65.xxx.xxx 未訂閱
Hi depblue,    1.Note: To use batch updating, the CursorType property of the dataset component must be either ctKeySet (the default) or ctStatic and the LockType property must be ltBatchOptimistic. 2.加入紅色字體部分試試看
with stga_reQu do
  begin
    Close;
    SQL.Clear;
    SQL.Add('select * from stga_re where gano = :p_gano');
    SQL.Add('and ordno = :p_ordno and stbno = :p_stbno');
    Parameters.ParamByName('p_gano').Value := stga_maQuGANO.Value;
    Parameters.ParamByName('p_ordno').Value := stga_deQuORDNO.Value;
    Parameters.ParamByName('p_stbno').Value := stga_deQuSTBNO.Value;
  Open;
end;    if (m_ts > 0) or (m_twei > 0) then =>這兩個變數都不等於0
  begin
    if stga_reQu.RecordCount = 0 then =>RecordCount也等於0
      begin
        stga_reQu.Insert;
        stga_reQuGANO.Value := stga_maQuGANO.Value;
        stga_reQuGA_DA.Value := stga_maQuGA_DA.Value;
        stga_reQuORDNO.Value := stga_deQuORDNO.Value;
        stga_reQuSTBNO.Value := stga_deQuSTBNO.Value;
        stga_reQuRE_PER_S.Value := m_ts;
        stga_reQuRE_PER_WEI.Value := m_twei;
        stga_reQu.Post;
        stga_reQu.UpdateBatch(arAll);
      end;
  end;
發表人 -
------
Fishman
系統時間:2024-05-19 5:39:47
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!