定义:
XMLStream:一个XML流包含一些行信息;
目前,我面临着一个奇怪的问题,称为“并发冲突”,虽然我做了一些调试工作,但仍然无法找到原因。所以,请帮帮我,谢谢。
1:通过读取XML流填充数据集:xmlDataSet.ReadXML(XMLStream);
2:从数据集中获取dataTable:DataTable xmlTable = xmlDataSet.Tables[OriTable.TableName];
3:修改dataTable的各行信息
foreach(DataRow xmlRow in xmlTable.rows)
{
DataRow targetRow = SearchRow(xmlRow); // search the xmlrow from the OriTable, and return it, in here, we assume it exists.
targetRow.ClearError();
targetRow.BeginEdit();
foreach(DataColumn xmlCol in xmlTable.columns)
{
if( OriTable.Columns.Contains(xmlCol.ColumnName)
{
// Modifying targetRow
}
}
targetRow.EndEdit();
}
if( // no error flag has been set)
{
OriTable.DataSet.UpdateTable(); // this is where the error appears
}请帮帮我,谢谢
PS: OriTable定义: ID: int not null,名称: nchar(40) not null默认'',描述: nchar(90) null,主键(Id)
发布于 2014-03-19 06:36:04
尝试使用'for‘循环代替'foreach’循环。在“foreach”循环中,您通常不能修改正在迭代的集合的项。
https://stackoverflow.com/questions/22492309
复制相似问题