PC Review


Reply
Thread Tools Rate Thread

Datarow delete- Implicit AccpetChanges on certain datasets

 
 
Matt
Guest
Posts: n/a
 
      9th Feb 2005
I have seen this question posted before but never answered.

If I load a DataSet from a database query, I need to call
AcceptChanges after DataRow.Delete to remove rows.

If I load a DataSet from an XML file or create one from scratch
programatically- DataRow.Delete removes rows immediately, seemingly
bypassing the rowstate and implicitly calling AccpetChanges. This
happens on single table datasets, so it is not a constraint related
issue.

This behavior doesn't appear to be documented. Any explanations?

Thanks
(originally posted by Scott Allen)

 
Reply With Quote
 
 
 
 
Miha Markic [MVP C#]
Guest
Posts: n/a
 
      9th Feb 2005
Hi Matt,

"Matt" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I have seen this question posted before but never answered.
>
> If I load a DataSet from a database query, I need to call
> AcceptChanges after DataRow.Delete to remove rows.


No, you shouldn't call AcceptChanges.
You will reset the rowstate and Update won't work because it won't see which
row was deleted.
AcceptChanges resets row state to unmodified.

>
> If I load a DataSet from an XML file or create one from scratch
> programatically- DataRow.Delete removes rows immediately, seemingly
> bypassing the rowstate and implicitly calling AccpetChanges. This
> happens on single table datasets, so it is not a constraint related
> issue.
>


Delete row either marks row as Deleted (a) or removes (b) the row .
a) when RowState is not Added
b) when RowState = Added


--
Miha Markic [MVP C#] - RightHand .NET consulting & development
www.rthand.com
SLODUG - Slovene Developer Users Group www.codezone-si.info

> This behavior doesn't appear to be documented. Any explanations?
>
> Thanks
> (originally posted by Scott Allen)
>



 
Reply With Quote
 
Cor Ligthert
Guest
Posts: n/a
 
      9th Feb 2005
Matt,

In addition to Miha.

When you don't want to update with the dataset the database anymore. You can
of course than use the acceptchanges.

However for that you can than use as well the commands
datarowcollection.remove and (at)

That has direct the same effect as calling after the delete the
acceptchanges. It removes the row direct from the collection and therefore
the rowstate cannot by used anymore.

Just a little addition.

Cor



 
Reply With Quote
 
Matt
Guest
Posts: n/a
 
      9th Feb 2005
This was the missing piece of the puzzle. Thanks!

>Delete row either marks row as Deleted (a) or removes (b) the row .
>a) when RowState is not Added
>b) when RowState = Added


 
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
Implicit Conversions in DataRow =?Utf-8?B?SGFycnkgVg==?= Microsoft C# .NET 0 23rd Jul 2007 05:40 PM
DataRow RowState Delete Techno_Dex Microsoft Dot NET Framework Forms 0 6th Oct 2006 04:44 PM
Delete DataRow in DataTable ? jez Microsoft Dot NET Compact Framework 11 16th Jan 2004 07:30 PM
Re: DataRow.Delete() Daniel Faensen Microsoft ADO .NET 0 29th Aug 2003 08:24 AM
What happens when you delete a DataRow ? Terry Burns Microsoft ADO .NET 2 15th Aug 2003 04:10 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:53 AM.