全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:4614
推到 Plurk!
推到 Facebook!

為什麼常常會有“找不到更新的資料列,最後讀取的值已被變更”的錯誤訊息。

答題得分者是:william
alice100001
一般會員


發表:21
回覆:49
積分:19
註冊:2002-09-14

發送簡訊給我
#1 引用回覆 回覆 發表時間:2002-12-31 11:29:05 IP:203.204.xxx.xxx 未訂閱
請問各位高手: 我用ado連access資料庫,常常在新增一筆資料後,接著再次修改此筆資料,在儲存的時候常會出現這個錯誤訊息(找不到更新的資料列,最後讀取的值已被變更”),並且不能儲存,為什麼會這樣呢?要如何才能避免?(我用refresh就不會了,但是若資料量多一點而已就會慢的不得了)拜託各位幫我想一下要怎麼辦好嗎?謝謝。
william
版主


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

發送簡訊給我
#2 引用回覆 回覆 發表時間:2002-12-31 11:37:26 IP:147.8.xxx.xxx 未訂閱
Do you have a key for the table? If not, maybe you could try to add an autonumber field as the key. 
alice100001
一般會員


發表:21
回覆:49
積分:19
註冊:2002-09-14

發送簡訊給我
#3 引用回覆 回覆 發表時間:2002-12-31 11:44:19 IP:203.204.xxx.xxx 未訂閱
我有加入key值但還是會有這個錯誤出現。 我不小心把這個主題post兩次,要怎麼刪除呢??
william
版主


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

發送簡訊給我
#4 引用回覆 回覆 發表時間:2002-12-31 11:55:31 IP:147.8.xxx.xxx 未訂閱
1) Try the lattest MDAC 2) make sure all operation is using the same ADOConnection (i.e. all ADOTable and ADOTable use a single ADOConnection) 3) Using defalult value? http://delphi.ktop.com.tw/topic.php?TOPIC_ID=23712
alice100001
一般會員


發表:21
回覆:49
積分:19
註冊:2002-09-14

發送簡訊給我
#5 引用回覆 回覆 發表時間:2002-12-31 12:24:59 IP:203.204.xxx.xxx 未訂閱
william謝謝你的回答,我看了那篇文章後,試了一下好像就不會出錯了,可是可以請問一下,要怎麼做才能像那篇文章一樣看出delphi有帶出哪些欄位呢? 謝謝!
william
版主


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

發送簡訊給我
#6 引用回覆 回覆 發表時間:2002-12-31 12:41:53 IP:147.8.xxx.xxx 未訂閱
引言:william謝謝你的回答,我看了那篇文章後,試了一下好像就不會出錯了,可是可以請問一下,要怎麼做才能像那篇文章一樣看出delphi有帶出哪些欄位呢? 謝謝!
I am sorry I cannot understand you question. A simple way is to fill in all fields after an insert (e.g. OnBeforeInsert of the dataset).
alice100001
一般會員


發表:21
回覆:49
積分:19
註冊:2002-09-14

發送簡訊給我
#7 引用回覆 回覆 發表時間:2002-12-31 12:52:17 IP:203.204.xxx.xxx 未訂閱
我的問題是,那篇文章的最後一個回應, mcho說:「因為 Access 的欄位(ServiceFee0)預設值為 0而Delphi新增UpdateBatch後欄位(ServiceFee0)卻未帶出,如果我再度更新按UpdateBatch後即出現錯誤,解決之道是不使用Access 的欄位(ServiceFee0)預設值;」。 他是如何看出欄位未帶出的? 另外依你的經驗來看這個情現是只有access會這樣,還是很多資料庫都會這樣呢?有哪些資料庫比較好用呢? 因為我寫程式才一年,用delphi才半年,沒有經驗,又都是自已看書的,也沒有比較深入的資料,只是覺的access似乎不太好用,想換一種資料庫,但不知該換哪一種。 先謝謝你的回答。
william
版主


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

發送簡訊給我
#8 引用回覆 回覆 發表時間:2002-12-31 17:19:44 IP:210.3.xxx.xxx 未訂閱
ic. Suppose there is a table A with 2 integer fields, F1 and F2, and both have default value of 0. With DBEdit1 linked with F1 and DBEdit2 linked with F2. After an insert both DBEdit1 and DBEdit2 will be empty (i.e. the fields are treated as empty) but actually the record in the Access mdb is F1=0 and F2=0. In this case if you try to edit the record via the 2 DBEdits will result in record not found since Delphi think F1 and F2 as empty and of course this record does not exist in the Access mdb. I think that the way to get default field value depends on the RDBMS you used and there is no standard way to do it. IMHO, Access is fine for standalone small projects since it comes with Windows 9x/Me/2000/XP and could be downloaded freely from Microsoft. BDE is dying so either ADO or dbExpress should be used in future project. 
系統時間:2024-05-15 20:46:28
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!