Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Delete Row
Message
General information
Forum:
ASP.NET
Category:
ADO.NET
Title:
Miscellaneous
Thread ID:
01459084
Message ID:
01459086
Views:
46
It's a very simple problem and should be listed in the foreach command reference. You can not remove member of a collection while enumerating it.

See Re: MisUnderstanding FOR EACH Thread #1329767 Message #1329799

>This seemingly simply process is throwing the error:
>
>
>Collection was modified; enumeration operation might not execute.
>
>
>Here's the code:
>
>
>public void ClearDataStore(string DataViewName)
>{
>    DataViewName = DataViewName.ToString().ToLower().Trim();
>    
>    foreach (DataRow Row in _dsDataStore.Tables[0].Rows)
>    {
>        if (Row["DataViewname"].ToString().ToLower().Trim() == DataViewName)
>        {
>            Row.Delete();
>        }
>    }
>
>    _dsDataStore.Tables[0].AcceptChanges();
>}
>
>
>What's the right way to remove rows from a DataSet????
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform