Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / ADO.NET / January 2006

Tip: Looking for answers? Try searching our database.

GetChanges question

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
WineNCheese - 26 Jan 2006 21:51 GMT
Can someone please tell me how the following is possible?  When I do this:

  System.Data.DataSet addedAndModified =  myDataset.GetChanges(
DataRowState.Added | DataRowState.Modified );

some of the rows in the resulting dataset have a RowState of
DataRowState.Deleted.
WineNCheese - 27 Jan 2006 00:15 GMT
More information below - my conclusion is this is a bug in ADO.NET.

I am using a dataset as a data cache in a winforms application.  In one of
the forms of the application, the user can perform actions which result in
the addition or deletion of rows in a table.  The user also has access to
Undo functionality.  If the user deletes a row (thus changing the RowState
to Deleted), and then performs an Undo (which recreates the row) there are
now two rows in the table with the same primary key.  One has a state of
Added, and one has a state of Deleted.   Then the user hits the save button.
In the resulting operation, I perform deletes first, followed by additions
and modifications.  For deletes, I ask for just the deleted rows using
GetChanges() and save all those changes successfully.  Then I ask for all
additions and modifications, and I get deleted rows as well in the case of
the undone deleted row.

My options currently, as I see them are:
1. Every time an undo is performed that results in a new row, remove all
rows with the same primary key that have a state of Deleted.  This results
in a problem though, because if the user performs a redo, the new row will
be deleted and moved to a detached state since it was in an inserted state.
Then, when the user goes to save, the row will not be deleted.

2. When I save additions and modifications, save on a row by row basis, and
skip the ones with Deleted state.
This seems to be my only real alternative.

Any suggestions are very welcome.

> Can someone please tell me how the following is possible?  When I do this:
>
[quoted text clipped - 3 lines]
> some of the rows in the resulting dataset have a RowState of
> DataRowState.Deleted.
WineNCheese - 27 Jan 2006 00:54 GMT
Even Further Clarification:

DataRow.GetChanges( DataRowState.Added | DataRowState.Modified ) does not
have this problem.  Thus, it is a bug with the Dataset version of
GetChanges.  I've removed my Dataset.GetChanges calls and replaced them with
DataRow.GetChanges calls for each table, and all works fine...

Thanx to Shams Mukhatar for the suggestion of trying the DataRow version...

WNC

> More information below - my conclusion is this is a bug in ADO.NET.
>
[quoted text clipped - 32 lines]
>> some of the rows in the resulting dataset have a RowState of
>> DataRowState.Deleted.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.