I have a parent WinForm with MyDataTable _dt as a member. The MyDataTable type was created in the "typed dataset" constructor tool in Visual Studio 2005 (MyDataTable inherits from DataTable) _dt populated from db via ADO.NET. Based on the changes in user interaction on the form, I delete the row from the table as follows:
_dt.FindBySomeKey(_someKey).Delete();
Later _dt is passed by value to the dialog form. From there, I need to scan all the lines in order to build the line:
foreach (myDataTableRow row in _dt) { sbFilter.Append("'" + row.info + "',"); }
The problem is that after this, the following exception is DeletedRowInaccessibleException: Deleted row information cannot be accessed through the row. after deletion: DeletedRowInaccessibleException: Deleted row information cannot be accessed through the row.
The work I'm currently using (which looks like a hack) is this:
foreach (myDataTableRow row in _dt) { if (row.RowState != DataRowState.Deleted && row.RowState != DataRowState.Detached) { sbFilter.Append("'" + row.info + "',"); } }
My question is: Is this the right way to do this? Why were the access strings for the foreach loop marked with the Delete() method?
Ken
source share