PC Review


Reply
Thread Tools Rate Thread

Delete vs. Remove

 
 
Tom Archer
Guest
Posts: n/a
 
      2nd Aug 2003
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?




 
Reply With Quote
 
 
 
 
Tom Archer
Guest
Posts: n/a
 
      2nd Aug 2003
>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?


Looks like I can't remove the row and then set up a view
to search on Detached rows as that is not a valid
DataViewRowState enumeration value. Therefore, it appears
like I need to change my steps to this:

3-1 Delete the row (and *don't* Remove)
3-2 Use the DefaultView when enumerating my table (instead
of the bare Rows collection
3-3 Create a DataView with Deleted as the filter in order
to display deleted rows and give the user the ability to
undo deletes.
 
Reply With Quote
 
Michael Lang
Guest
Posts: n/a
 
      4th Aug 2003
You may have misinterpreted the text? The DataRowCollection.Remove() is not
meant to "delete" the record. It only removes it from the collection. To
delete a record from the database, you must use DataRow.Delete(). If the
text contradicts what I've just stated then you should inform the author,
and hope he posts a correction on the books website.

Michael Lang, MCSD

"Tom Archer" <(E-Mail Removed)> wrote in message
news:004c01c35923$5b312260$(E-Mail Removed)...
> >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?

>
> Looks like I can't remove the row and then set up a view
> to search on Detached rows as that is not a valid
> DataViewRowState enumeration value. Therefore, it appears
> like I need to change my steps to this:
>
> 3-1 Delete the row (and *don't* Remove)
> 3-2 Use the DefaultView when enumerating my table (instead
> of the bare Rows collection
> 3-3 Create a DataView with Deleted as the filter in order
> to display deleted rows and give the user the ability to
> undo deletes.



 
Reply With Quote
 
Tom Archer
Guest
Posts: n/a
 
      4th Aug 2003
It's one of those situations where the author's text is
very misleading. It makes sense after some testing, but
that's what the book is supposed to do for me - save time.
Oh well. The majority of the book is good. It's just weak
in this a few other areas.
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Cannot delete in Add and Remove David B. Windows XP Help 1 10th Jun 2009 10:33 PM
Delete or Remove? Marty Microsoft Windows 2000 Networking 1 26th Jul 2006 04:06 PM
Remove Windows Hotfixes from the Add/Remove Programs control and delete from hard disk moxy_fruvus@yahoo.com Microsoft Windows 2000 2 9th Nov 2005 09:57 PM
How do delete or remove D Windows XP General 3 19th Nov 2003 05:42 PM
RE: HELP on Delete vs Remove ?? calderara serge Microsoft ADO .NET 1 22nd Jul 2003 12:30 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:14 PM.