本文介绍了并发冲突 - 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

解决方案




我认为ChangedRows是dataset.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行)这一切似乎都很好。



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
cancelledFALSEbool
dancerid6int
finishedTRUEbool
len20byte
pclub30short
pdancer55short
privateid65int
roomAstring
+shift{8/2/2004}System.DateTime
start20:20string
+tabletbprivate{Dancers.allbookings.tbprivateDataTable}
Dancers.allbookings.tbprivateDataTable
ChangedRows.Tables["tbprivate"].Rows[0].RowError
Concurrency violation: the UpdateCommand affected 0 records.string

解决方案



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




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.



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

09-25 11:18