請教新增一筆資料進到資料庫~~ |
答題得分者是:Fishman
|
depblue
一般會員 發表:38 回覆:29 積分:13 註冊:2004-12-27 發送簡訊給我 |
|
pillar62
資深會員 發表:9 回覆:324 積分:271 註冊:2002-04-15 發送簡訊給我 |
|
depblue
一般會員 發表:38 回覆:29 積分:13 註冊:2004-12-27 發送簡訊給我 |
引言: 請問: 我在新增一筆資料進入資料庫時, 有時資料可以更新進去,有時資料卻沒有更新進到資料庫, 那一筆沒更新的資料再更新一次,又可以進去了, 請問,這是什麼問題,又怎麼解決?? @@我的資料庫是使用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 發送簡訊給我 |
引言: 請問: 我在新增一筆資料進入資料庫時, 有時資料可以更新進去,有時資料卻沒有更新進到資料庫, 那一筆沒更新的資料再更新一次,又可以進去了, 請問,這是什麼問題,又怎麼解決?? @@我的資料庫是使用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 發送簡訊給我 |
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 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |