T
Tom Archer
I'm trying to clarify the key differences between these
two methods:
1) An ADO.NET book that I'm reading states that both
DataRow:elete and DataRowCollection::Remove are used to
delete rows. My testing indicates that Delete deletes the
row (sets DataRow::State to Deleted and deletes the row
from the data store upon DataAdapter::Update). On the
other hand, Remove simply removes the row from the
collection (sets the DataRow::State to Detached) and
DataAdapter::Update does *not* remove the row. Therefore,
it appears as though the book is incorrect or am I
misunderstanding something?
2) If I call Delete and then call Remove, the
DataRowCollection::Count remains the same as before the
Delete. However, reversing these calls does detach the row
and then mark it for deletion. This leads me to believe
that internally the DataRowCollection won't remove a row
designated as Deleted. Is that true?
3) The previous two points leads me to believe that if I
wanted to give the user the ability to view deleted rows
so that they could undo a deletion, I could:
3-1) Remove *and* Delete the row so that the DefaultView
won't show it and it would be deleted upon updating the
data adapter.
3-2) Use a second view in order to enumerate rows marked
as Deleted so that the user can select from them if they
want to undo a delete. Is this correct?
two methods:
1) An ADO.NET book that I'm reading states that both
DataRow:elete and DataRowCollection::Remove are used to
delete rows. My testing indicates that Delete deletes the
row (sets DataRow::State to Deleted and deletes the row
from the data store upon DataAdapter::Update). On the
other hand, Remove simply removes the row from the
collection (sets the DataRow::State to Detached) and
DataAdapter::Update does *not* remove the row. Therefore,
it appears as though the book is incorrect or am I
misunderstanding something?
2) If I call Delete and then call Remove, the
DataRowCollection::Count remains the same as before the
Delete. However, reversing these calls does detach the row
and then mark it for deletion. This leads me to believe
that internally the DataRowCollection won't remove a row
designated as Deleted. Is that true?
3) The previous two points leads me to believe that if I
wanted to give the user the ability to view deleted rows
so that they could undo a deletion, I could:
3-1) Remove *and* Delete the row so that the DefaultView
won't show it and it would be deleted upon updating the
data adapter.
3-2) Use a second view in order to enumerate rows marked
as Deleted so that the user can select from them if they
want to undo a delete. Is this correct?