Understanding the Delete and Remove methods - datarow object

Posted on 2007-10-04
Last Modified: 2012-06-21
In a DataRow object we have the methods Delete and Remove.
The Delete method marks the row for deletion by changing the RowState property to Delete and hidding the row.
My question is about the Remove method.
It says that it completely revomes the row from the DataRowCollection, but what happens with that row when we save the changes in the dataset to the database?
In understand perfectly what happens when we use the Delete method, but the Remove method is not clear to me.
Also, if we use the Delete method, the row will be hidden and changed to Delete state. How can I undo this operation and bring the row back to its original state?

Question by:andrepires
    LVL 16

    Accepted Solution

    The Remove method removes the row from the datatable, so when you do an update, it doesn't do anything to that row (will not delete from database).  If it's deleted, then when you do an update, the deletecommand on your adapter is used (deletes from database).
    LVL 16

    Expert Comment

    Use RejectChanges to restore the row.

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
    Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now