473,573 Members | 2,905 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DataSet's GetChanges() w/ a webapp working in disconnected mode


i have a web app that allows users to query our oracle db and produce a
dataset of report data. they then have the option to serialize this
data and store it in the database. later, then can re-run the report
and get fresh data. now, they would like to be able to compare the
fresh data to the stored data, getting a break-down of
added/deleted/changed rows.

on the surface, this sounded plausible -- by deserializing the stored
dataset, i have access to both the original dataset & the fresh
dataset. it's my understanding then that these two can be merged w/ a
third dataset to produce the differences, like so:

//get the two datasets data
DataSet historic = GetHistoricData ();
DataSet current = GetCurrentData( );

//make merge container
DataSet merged = new DataSet();

//seed w/ orig data
merged.Merge(hi storic);
merged.AcceptCh anges();

//merge w/ new data
merged.Merge(cu rrent);

//and get the differences
DataSet added = merged.GetChang es(DataRowState .Added);
DataSet deleted = merged.GetChang es(DataRowState .Deleted);
DataSet modified = merged.GetChang es(DataRowState .Modified);
....however, that isnt quite working for me. forgetting about the
serializing/deserializing, and working w/ dummy data, i simply cannot
get the GetChanges() methods to work as expected.

here is my code:

public static DataSet GetHistoricData ()
DataTable dt = new DataTable();
dc = dt.Columns.Add( "PersonID",
System.Type.Get Type("System.In t32"));
dt.PrimaryKey = new DataColumn[1] { dc };
dt.Columns.Add( "FirstName" , System.Type.Get Type("System.St ring"));
dt.Columns.Add( "LastName", System.Type.Get Type("System.St ring"));
dt.Columns.Add( "Comments", System.Type.Get Type("System.St ring"));

dt.Rows.Add( new Object[4] { 66, "matt", "smith", "shipped to
office" } );
dt.Rows.Add( new Object[4] { 67, "jonnie", "tyler", "shipped to
home" } );
dt.Rows.Add( new Object[4] { 68, "cory", "default", "shipped to
home" } );

DataSet ds = new DataSet();
ds.Tables.Add(d t);
return ds;

//''''''''''''''' ''''''''''''''' ''''''''''''''' '''''''

public static DataSet GetCurrentData( )
DataTable dt = new DataTable();
dc = dt.Columns.Add( "PersonID",
System.Type.Get Type("System.In t32"));
dt.PrimaryKey = new DataColumn[1] { dc };
dt.Columns.Add( "FirstName" , System.Type.Get Type("System.St ring"));
dt.Columns.Add( "LastName", System.Type.Get Type("System.St ring"));
dt.Columns.Add( "Comments", System.Type.Get Type("System.St ring"));

//row stayed the same:
dt.Rows.Add( new Object[4] { 66, "matt", "smith", "shipped to
office" } );

//(row for PersonID 67 was deleted)

//row changed:
dt.Rows.Add( new Object[4] { 68, "cory", "default", "shipped to
OFFICE" } );

//new row added:
dt.Rows.Add( new Object[4] { 69, "rich", "demel", "lives in hawaii"
} );

DataSet ds = new DataSet();
ds.Tables.Add(d t);
return ds;
but the GetChage() results im getting:
- dataset "added" correctly reports the addition of the new row (person

- dataset "modified" does correctly list person 68 (comments changed),
but it also lists person 66, which had no change.

- dataset "deleted" doesnt have any rows. i was hoping it would list
rows present in "historic" but lacking in "current" (indicating they
had been removed)...
any ideas? is what im trying to do possible, or is this not how
GetChanges() was designed to work?

Oct 24 '06 #1
1 2511
ok, i have a solution for this. never did get the dataset's built-in
methods to do the job.

i found another post that lead to this blog:


....which got me half-way there. that nifty little function gives you
the differences between two same-schema tables. that is, rows from one
that are not in the second.

by running that on the "current" and "historic" datasets, i can get
tables of added & deleted rows. then, using another helper i wrote, i
can determine which delta rows were actual modifications. using these
together gets me a clean black box method that, when given two
datatables, produces a three-tabled dataset: one each for added,
deleted, and modified rows. sweet.

Oct 25 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: Niyazi | last post by:
Hi, I have not understand the problem. Before all the coding with few application everything worked perfectly. Now I am developing Cheque Writing application and when the cheque is clear the user have to open a form and entera date so we know in report that the desiered check has been cleared. It takes me while to wrtie. But when I try...
by: Marty | last post by:
In winforms, I can bind a datagrid to a dataset. When the user wants to submit changes, it's easy to see what has changed with the DataSet "GetChanges" method. In ASP.Net, I can create the dataset, bind it to the grid, then send to the user. But upon postback, I have no way of knowing which items changed on the datagrid. Do I really have to...
by: Graham Blandford | last post by:
Hi all, Would someone be able to tell me the most 'graceful' way of removing unwanted rows from a dataset based on a condition prior to update? OR, resetting the rows all to unchanged after they are initally added to the recordset. I create a dataset, which begins empty after the initial .Fill. Then I create several rows with some...
by: Peter Proost | last post by:
Hello group, what would be the best way to do the next thing: I've got a grid form with about 15000 records, when I double click a row a detail form is opened and the user can modify and save the record, this all works just fine, then the user closes the detail form and ofcourse I want to show his modifications in the grid form, but now my...
by: Anthony Malt | last post by:
Hi, my server has a database table. I read this table on the server into a dataset and my client retrieves it through a webservice. No changes on the client and server happen. What's the best way to keep the data in sync? I want to avoid that I transfer the entire dataset all the time. Is there a way just to send/receive the changes?
by: Al | last post by:
I have this scenario: 1. XML file with schema and data is created from SQL Server tables. XML file contains 6 tables, some of them have rows, some of them are empty. 2. XML file is given to the person with Pocket PC. 3. XML file is used to populate DataSet on the Pocket PC. 4. User adds new rows, changes values, deletes some rows. 5. Altered...
by: mike11d11 | last post by:
I'm trying to create an application that will have multiple users working off a table on a SQL server. Since multi users will be updating different records at any given moment, how can i get those changes and merge them into my current Dataset. I've been playing around with the GetChanges method and Acceptchanges but they just dont seem to...
by: Mark Chambers | last post by:
Hi there, Can anyone explain the following (very) simple scenario. 1) I make an exact copy of my "DataSet" and delete one record from a given table (in the copy) 2) I invoke "DataSet.GetChanges()" on the above copy and pass the results to "DataSet.Merge()" on the original copy 3) If I now inspect the original copy, it shows that the...
by: John Sheppard | last post by:
Hello there, I have the following code; I do this as a work around for a dataset.haschanges method which doesnt appear to work correctly either For Each dt As DataTable In myDs.Tables If Not dt.GetChanges(DataRowState.Added) Is Nothing Then hasChanges=true If Not dt.GetChanges(DataRowState.Modified) Is Nothing Then hasChanges=true If...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.