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

Access資料庫新增一筆資料再度更新時,發生找不到更新列!

答題得分者是:william
mcho
初階會員


發表:57
回覆:106
積分:42
註冊:2002-11-11

發送簡訊給我
#1 引用回覆 回覆 發表時間:2002-12-09 16:29:00 IP:61.224.xxx.xxx 未訂閱
大家好!我使用Delphi 5 以 Access2000為資料庫 ADO,目前資料已達2萬餘筆 有一個問題一直困擾,就是新增一筆資料UpdateBatch後 再度更新後執行UpdateBatch時,即發生錯誤"找不到更新列,最後讀數已被變更"! 目前我的解決方式,就是執行UpdateBatch之後同時CLOSE再OPEN,但是還要 加一LOCATE指令回到原來那筆資料,太麻煩! 請問那位高手是否有更好解決方法,謝謝! (我使用元件是ADOQuery) 何明昌 發表人 - mcho 於 2002/12/09 16:32:12 發表人 - mcho 於 2002/12/09 16:37:34 發表人 - mcho 於 2002/12/09 17:59:53
------
何明昌
william
版主


發表:66
回覆:2535
積分:3048
註冊:2002-07-11

發送簡訊給我
#2 引用回覆 回覆 發表時間:2002-12-09 16:58:25 IP:147.8.xxx.xxx 未訂閱
Just a thought, tried setting the TADOTable.TableDirect to True?
mcho
初階會員


發表:57
回覆:106
積分:42
註冊:2002-11-11

發送簡訊給我
#3 引用回覆 回覆 發表時間:2002-12-09 17:16:17 IP:61.224.xxx.xxx 未訂閱
引言: Just a thought, tried setting the TADOTable.TableDirect to True?
William:你好! 謝謝你的setting the TADOTable.TableDirect to True 但是我使用的是 ADOQuery 沒有Direct之屬性該如何是好?可否指點一下!下圖示是錯誤訊息: 發表人 - mcho 於 2002/12/10 10:48:13
------
何明昌
william
版主


發表:66
回覆:2535
積分:3048
註冊:2002-07-11

發送簡訊給我
#4 引用回覆 回覆 發表時間:2002-12-10 11:04:12 IP:147.8.xxx.xxx 未訂閱
I wonder it cannot locate the key for the records. Are all you ADO datasets using the same ADOConnection? If possible, could you give some more details on the table strucutre, and probably some codes for insert and update?
mcho
初階會員


發表:57
回覆:106
積分:42
註冊:2002-11-11

發送簡訊給我
#5 引用回覆 回覆 發表時間:2002-12-10 12:19:35 IP:61.224.xxx.xxx 未訂閱
引言: I wonder it cannot locate the key for the records. Are all you ADO datasets using the same ADOConnection? If possible, could you give some more details on the table strucutre, and probably some codes for insert and update?
William你好! 我只用二個ADO元件如下圖: 檔案結構如下: 1.AccYear:文字,Length=3 2.Accid:文字,Length=9 3.ServiceFee0:單精準數,小數=2,預設=0 4.ServiceFee:單精準數,小數=0,預設=0 key=AccYear+Accid 我會將整個code(test.zip)寄給你,但我不知如何傳給你? 何明昌 發表人 - mcho 於 2002/12/10 12:33:03 發表人 - mcho 於 2002/12/10 12:36:24
------
何明昌
william
版主


發表:66
回覆:2535
積分:3048
註冊:2002-07-11

發送簡訊給我
#6 引用回覆 回覆 發表時間:2002-12-10 12:39:21 IP:147.8.xxx.xxx 未訂閱
Hi mcho, maybe you can uplaod the test to 會員求助程式檔案上傳區. BTW, is there any key in your table? If not, you may want to try creating a key (e.g. using auto number).
mcho
初階會員


發表:57
回覆:106
積分:42
註冊:2002-11-11

發送簡訊給我
#7 引用回覆 回覆 發表時間:2002-12-10 12:51:53 IP:61.224.xxx.xxx 未訂閱
引言: Hi mcho, maybe you can uplaod the test to 會員求助程式檔案上傳區. BTW, is there any key in your table? If not, you may want to try creating a key (e.g. using auto number).
嗨William Test.zip已上傳了 http://delphi.ktop.com.tw/loadfile.php?TOPICID=7433450&CC=166250 何明昌
------
何明昌
william
版主


發表:66
回覆:2535
積分:3048
註冊:2002-07-11

發送簡訊給我
#8 引用回覆 回覆 發表時間:2002-12-10 14:29:08 IP:147.8.xxx.xxx 未訂閱
Hi mcho, I have no problem is using your program (on W2K Pro SP3, I think I should have the latest MDAC) directly. It also works fine under my copy of Delphi 7 Ent. Maybe you can try on some machines with the latest MDAC?
mcho
初階會員


發表:57
回覆:106
積分:42
註冊:2002-11-11

發送簡訊給我
#9 引用回覆 回覆 發表時間:2002-12-10 15:00:00 IP:61.224.xxx.xxx 未訂閱
引言: Hi mcho, I have no problem is using your program (on W2K Pro SP3, I think I should have the latest MDAC) directly. It also works fine under my copy of Delphi 7 Ent. Maybe you can try on some machines with the latest MDAC?
Hi William,測試時新增一筆資料時ServiceFee0,ServiceFee先不輸入資料 先按UpdateBatch後再輸入ServiceFee0欄後再按UpdateBatch試試看 何明昌
------
何明昌
william
版主


發表:66
回覆:2535
積分:3048
註冊:2002-07-11

發送簡訊給我
#10 引用回覆 回覆 發表時間:2002-12-10 16:10:54 IP:147.8.xxx.xxx 未訂閱
Hi mcho, I can reproduce the problem now. It seems that the field ServiceFee0 and ServiceFee cannot get their default values after the insert. Maybe you can fill in the default value before inserting it or just do a ADOQuery1.Refresh (slow...) after the update?
mcho
初階會員


發表:57
回覆:106
積分:42
註冊:2002-11-11

發送簡訊給我
#11 引用回覆 回覆 發表時間:2002-12-10 16:39:15 IP:61.224.xxx.xxx 未訂閱
引言: Hi mcho, I can reproduce the problem now. It seems that the field ServiceFee0 and ServiceFee cannot get their default values after the insert. Maybe you can fill in the default value before inserting it or just do a ADOQuery1.Refresh (slow...) after the update?
Hi William, 謝謝!我現在知道了!因為 Access 的欄位(ServiceFee0)預設值為 0而Delphi新增UpdateBatch後欄位(ServiceFee0)卻未帶出,如果我再度更新按UpdateBatch後即出現錯誤,解決之道是不使用Access 的欄位(ServiceFee0)預設值;謝謝! 何明昌
------
何明昌
系統時間:2024-05-19 18:02:56
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!