O
Osvaldo Bisignano
Hi guys n girls.
I get this error when updating my datatable:
foreach(DataRow dr in myTable.Rows)
{
try
{
MyCustomUpdater.Update(dr); //not a DataAdapter, a custom object.
//If no exception has been thrown
dr.AcceptChanges();
}
catch (Exception ex)
{
throw ex;
}
}
If the row has been deleted, when I call AcceptChanges the row is removed from the datatable, and after that the collection is modified, and foreach throws an error saying that the Collection has been modified and the Enumerator is not valid any more.
I need to accept changes inmediatly after each row has been succesfully updated to the database.
How can i avoid this situation?
How does the SQlDataAdapter.Update method resolves this?
Thanks
I get this error when updating my datatable:
foreach(DataRow dr in myTable.Rows)
{
try
{
MyCustomUpdater.Update(dr); //not a DataAdapter, a custom object.
//If no exception has been thrown
dr.AcceptChanges();
}
catch (Exception ex)
{
throw ex;
}
}
If the row has been deleted, when I call AcceptChanges the row is removed from the datatable, and after that the collection is modified, and foreach throws an error saying that the Collection has been modified and the Enumerator is not valid any more.
I need to accept changes inmediatly after each row has been succesfully updated to the database.
How can i avoid this situation?
How does the SQlDataAdapter.Update method resolves this?
Thanks