并发冲突错误 [英] Concurrency violation error

查看:120
本文介绍了并发冲突错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好

在此代码中:

Hello

in this code:

SqlConnection CON1 = new SqlConnection();
CON1.ConnectionString = DATAPROVIDER.DataProvider.ConnectionString;
CON1.Open();
SqlCommand b21 = new SqlCommand("select * from " + DetailTableName);
GridEXTable _table1 = ((GridEX)ChildControl).RootTable;
SqlDataAdapter sda1 = new SqlDataAdapter(b21.CommandText, CON1);
SqlCommandBuilder cmb1 = new SqlCommandBuilder(sda1);
cmb1.GetDeleteCommand();
sda1.Update(table);
CON1.Close();


我收到此错误:

并发冲突:UpdateCommand影响了预期的1条记录中的0条.

请帮帮我.
谢谢


I recieve this error:

Concurrency violation: the UpdateCommand affected 0 of the expected 1 records.

Please help me.
Thanks

推荐答案

您可能正在尝试更新不存在的行.

如果您搜索错误消息,将获得7700多个结果.

You''re probably trying to update a row that doesn''t exist.

If you google the error message, you''ll get over 7700 results back.

This one [^] is pretty useful.


这种情况在您尝试更新或删除找不到的记录,该记录可能已被删除,或者您正在使用并发记录.
this occours when you''re trying to update or delete a record that cannot be found, it could have been deleted or you''re using concurrency.


如前所述,这通常是适配器无法找到记录的情况.行进行更新.但是,在您的代码中,调用变量table的数据适配器的更新.但是,在您发布的代码中,您似乎根本没有填写该表?另外,您无需对表格进行任何修改.

您引用的是正确的变量还是帖子中缺少某些内容?

附带说明一下,GetDeleteCommand似乎毫无意义,因为您没有将返回的对象放在任何变量中.
As already said this is typically a situation where the adapter cannot find a row to update. However, in your code you call the update of the dataadapter for variable table. However in the code you posted, you don''t seem to fill this table at all? Also you don''t make any modifications to the table.

Are you referencing a correct variable or is something missing from the post?

As a side-note the GetDeleteCommand seems pointless since you don''t put the returning object to any variable.


这篇关于并发冲突错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆