Dmitry,
The easier way would be to cycle through the rows backwards (using an
index), and then call the delete method on them while you cycle backwards,
like this:
// Cycle backwards.
for (int pintIndex = MyDataSet["MyTable"].Rows.Count - 1; pintIndex >= 0;
pintIndex--)
// Delete the row.
MyDataSet["MyTable"].Rows[pintIndex].Delete();
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
-
mv*@spam.guard.caspershouse.com
"Dmitry Karneyev" <ka******@msn.com> wrote in message
news:ei*************@tk2msftngp13.phx.gbl...
Hi!
I try to delete rows from the table in such way
foreach(DataRow row in MyDataSet.MyTable)
{
row.Delete();
}
and recive an error that collection is changed and enumeration is
impossible.
I guesss that foraech operator uses collection of undeleted rows and this
causes such behaviour.
Is there another approach to mark all rows in the table to deleted state?
Thanks
Dmitry