并发冲突 - concurrency_error_watch.xls(0/1) [英] Concurrency violation - concurrency_error_watch.xls (0/1)

查看:68
本文介绍了并发冲突 - concurrency_error_watch.xls(0/1)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在从数据网格更新时遇到问题。它说并发

违规:UpdateCommand影响了0条记录,但我看不出

它是如何与并发相关的;。我可以插入和删除没有

的问题。这是导致问题的代码:


public void UpdateDataSource(Dancers.allbookings ChangedRows)

{

尝试

{

if((ChangedRows!= null))

{

this.oleDbConnection1。打开();

oleDbDataAdapter1.Update(ChangedRows);

}

}

catch(System.Exception updateException)

{

抛出updateException;

}

终于

{

this.oleDbConnection1.Close();

}


}


An尝试执行该行时发生错误:


oleDbDataAdapter1.Update(ChangedRows);


尝试从手表追踪时发现没有错列出要更新的行中的

数据,如下所示(可以从附加的excel文件中查看更清楚

):


- ChangedRows.tbprivate [0]

{Dancers.allbookings.tbprivateRow}

舞者。 allbookings.tbprivateRow

+ System.Data.DataRow {Dancers.allbookings.tbprivateRow}

System.Data.DataRow

取消FALSE bool

dancerid 6 int

完成TRUE布尔

len 20字节

pclub 30短

pdancer 55 short

privateid 65 int

room A string

+ shift {8/2/2004} System.DateTime

开始20:20字符串

+ tabletbprivate {Dancers.allbookings.tbprivateDataTable}

Dancers.allbookings.tbprivateDataTable

ChangedRows.Tables [ " tbprivate"]。行[0] .RowError

并发冲突:UpdateCommand影响了0条记录。 string

解决方案

你好尼克,


当你这样做时,

oleDbDataAdapter1.Update(ChangedRows);




我认为ChangedRows是dataset.ChangedRows而不是acceptchanges

不是自动完成的oleDbDataAdapter,下次你进行更新时会得到并发错误。


可以吗?


Cor


On Tue,2004年2月10日13:37:59 +0100,Cor < no*@non.com>写道:

嗨尼克,

当你这样做时,

oleDbDataAdapter1.Update(ChangedRows);


我认为ChangedRows是数据集.ChangedRows而不是acceptchanges
不是由oleDbDataAdapter自动完成的,下次你进行更新时会得到并发错误。

可以吗?

Cor




好​​了这里'代码序列:当按下更新按钮,

" UpdateDataSet"被称为:


public void UpdateDataSet()

{

Dancers.allbookings objDataSetChanges = new

Dancers.allbookings();


this.BindingContext [objallbookings," tbprivate"]。EndCurrentEdit();

objDataSetChanges =

((Dancers.allbookings)(objallbookings.GetChanges()));


//检查是否有任何更改。

if((objDataSetChanges!= null))

{

试试

{

this.UpdateDataSource(objDataSetChanges) ;

objallbookings.Merge(objDataSetChanges);

objallbookings.AcceptChanges();

}

catch(系统.Exception eUpdate)

{

throw eUpdate;

}

}

然后调用UpdateDataSource的
来自:

this.UpdateDataSource(objDataSetChanges);


" objDataSetChanges"作为ChangedRows传入

UpdateDataSource。如前所述,当执行

" oleDbDataAdapter1.Update(ChangedRows)时,它会崩溃。在UpdateDataSource中。我怀疑是否有一些数据不一致,但是看看

" ChangeRows" (在这种情况下只有1行)这一切似乎都很好。


Hello Nick,


感谢您的帖子。据我所知,你遇到的问题是,当调用DbDataAdapter.Update方法时,它会抛出DBConcurrencyException。

默认情况下,Update方法结束并引发DBConcurrencyException 异常。我认为

在继续前进之前需要更多信息:


1.数据库,SQL Server,Microsoft Access等是什么?


2.在DataRow中,它是否包含用于映射DateTime数据的System.Data.OleDb.OleDbType.DBDate

类型?如果是这样,根据我的经验,有一个

已知问题导致此类错误,我们需要使用

System.DataOleDb.OleDbType.Date而不是

System.Data.OleDb.OleDbType.DBDate。


3.如果问题仍然存在,您是否可以发布示例项目

和能够重现问题的数据库?我很高兴

检查一下。


我期待着您的回复。


问候,


HuangTM

微软在线合作伙伴支持

MCSE / MCSD


安全! - www.microsoft.com/security

发布是按原样提供的。没有保证,也没有赋予任何权利。


I''m having trouble updating from a datagrid. It''s says "Concurrency
violation: the UpdateCommand affected 0 records", though I can''t see
how it''s related to "concurrency". I can insert and delete with no
problem. Here''s the code that''s causing the problem:

public void UpdateDataSource(Dancers.allbookings ChangedRows)
{
try
{
if ((ChangedRows != null))
{
this.oleDbConnection1.Open();
oleDbDataAdapter1.Update(ChangedRows);
}
}
catch (System.Exception updateException)
{
throw updateException;
}
finally
{
this.oleDbConnection1.Close();
}

}

An error occurs trying to execute the line:

oleDbDataAdapter1.Update(ChangedRows);

I found nothing wrong when trying to track from the watch list the
data from the row to be updated, as below (can be viewed a lot clearer
from the attached excel file):

- ChangedRows.tbprivate[0]
{Dancers.allbookings.tbprivateRow}
Dancers.allbookings.tbprivateRow
+ System.Data.DataRow {Dancers.allbookings.tbprivateRow}
System.Data.DataRow
cancelled FALSE bool
dancerid 6 int
finished TRUE bool
len 20 byte
pclub 30 short
pdancer 55 short
privateid 65 int
room A string
+ shift {8/2/2004} System.DateTime
start 20:20 string
+ tabletbprivate {Dancers.allbookings.tbprivateDataTable}
Dancers.allbookings.tbprivateDataTable
ChangedRows.Tables["tbprivate"].Rows[0].RowError
Concurrency violation: the UpdateCommand affected 0 records. string

解决方案

Hi Nick,

When you do it this way,

oleDbDataAdapter1.Update(ChangedRows);



I asume that ChangedRows is the dataset.ChangedRows than the acceptchanges
is not done automaticly by the oleDbDataAdapter, the next time you do than
an update you get a concurrency errror.

Can it be that?

Cor


On Tue, 10 Feb 2004 13:37:59 +0100, "Cor" <no*@non.com> wrote:

Hi Nick,

When you do it this way,

oleDbDataAdapter1.Update(ChangedRows);



I asume that ChangedRows is the dataset.ChangedRows than the acceptchanges
is not done automaticly by the oleDbDataAdapter, the next time you do than
an update you get a concurrency errror.

Can it be that?

Cor



OK here''s the code sequece: When the update button is pressed,
"UpdateDataSet" is called:

public void UpdateDataSet()
{
Dancers.allbookings objDataSetChanges = new
Dancers.allbookings();

this.BindingContext[objallbookings,"tbprivate"].EndCurrentEdit();
objDataSetChanges =
((Dancers.allbookings)(objallbookings.GetChanges() ));

// Check to see if any changes have been made.
if ((objDataSetChanges != null))
{
try
{
this.UpdateDataSource(objDataSetChanges);
objallbookings.Merge(objDataSetChanges);
objallbookings.AcceptChanges();
}
catch (System.Exception eUpdate)
{
throw eUpdate;
}
}
}

which then calls "UpdateDataSource" from:

this.UpdateDataSource(objDataSetChanges);

"objDataSetChanges" is passed in as "ChangedRows" to
"UpdateDataSource". As mentioned before, it breaks down when executing
"oleDbDataAdapter1.Update(ChangedRows)" within "UpdateDataSource". I
suspect there''s some data inconsistency but by looking at the
"ChangeRows" (which only have 1 row in this case) it all seems fine.


Hello Nick,

Thanks for your post. As I understand, the problem you are facing is that
it throws DBConcurrencyException when calling DbDataAdapter.Update method.
By default, the Update method ends and raises a DBConcurrencyException
exception when the method encounters a row that fails to update. I think
more information is needed before moving forward:

1. What''s the database, SQL Server, Microsoft Access, etc?

2. In the DataRow, does it contain the "System.Data.OleDb.OleDbType.DBDate"
type for mapping DateTime data? If so, based on my experience, there is a
known issue to cause such error and we need to use
System.DataOleDb.OleDbType.Date instead of
System.Data.OleDb.OleDbType.DBDate.

3. If the problem persists, is it possible for you to post a sample project
and database which is able to reproduce the problem? I will be glad to
check it on my side.

I look forward to hearing from you.

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.


这篇关于并发冲突 - concurrency_error_watch.xls(0/1)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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