473,903 Members | 6,152 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Merging two datasets deletes parent elements, preserves all children


My problem: Merging two datasets deletes parent elements, preserves
all children.

I've created two dataSets. Each use the same schema, parent-child
nested tables.

The first dataSet is loaded with historical data read from an XML
file. The second dataSet has current data filled from a dataGrid.
The system takes selected dataGrid data, dataSet updates a child
element value, merges with the first dataSet, and finally writes out
the latest version of the history file.

Inside the file, there is a mix of parent table elements and children.
All the children are preserved and correct, but are assigned to a
subset of parent elements. Most often only two parent elements, the
first two, are created. The children of the first and second parent
elements are properly assigned. But the rest of the children are
assigned to either parent element in a repeatable pattern depending on
which row of the dataGrid is selected. Using AcceptChanges creates a
single parent element that holds all the children.

Thanks in advance.

My environment: .NET, framework 1.1, C#, windows forms, VS 2003.
// Create dataSet to store dataGrid data

dsNew = null;
dsNew = new DataSet();
dsNew.ReadXmlSc hema("xmlFile.x sd");

// Create dataSet to store history file

dsHistory = null;
dsHistory = new DataSet();
dsHistory.ReadX mlSchema("xmlFi le.xsd");
dsHistory.ReadX ml("xmlFile.xml ");
// Populate Parent table from dataGrid dataSet
DataTable dayNew = dsNew.Tables["Day"];

foreach(DataRow copyRow in dayRows)
dayNew.ImportRo w(copyRow);
// Populate Child table from dataGrid dataSet
DataTable reqNew = dsNew.Tables["Request"];

foreach(DataRow copyRow in reqRows)
reqNew.ImportRo w(copyRow);
DataRow daRow;

// Loop through update rows based on
// number of children rows selected in datagrid

for(int i = rowCount - 1; this.threshold - 1 < i; i--)
// assign the row
daRow = dsNew.Tables["Request"].Rows[i];
// Set the "Accept" column false
daRow[2] = false;

// Merge the historical and new dataGrid dataSet

dsNew.Merge(thi s.dsHistory);

dsNew.WriteXml( "xmlFile.xm l", XmlWriteMode.Ig noreSchema);

dsNew.Dispose() ;
dsHistory.Clear ();
dsHistory.Dispo se();
Nov 12 '05 #1
0 2909

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

Similar topics

by: Natehop | last post by:
I've been attempting to design an n-tiered framework leveraging .NET's strongly typed Dataset. My Framework will serve as the foundation to several client apps from Windows applications to web sites and web services. The architecture consists of a business rules tier, a data tier, and a common tier. The common tier contains my typed Datasets while the business rules and data tiers contain functions to populate and save the common...
by: feanor | last post by:
I need to select children checkboxes when selecting the parent one. This is my function: function SelectChildrens(checkbox_name){ form = document.forms; Sname = checkbox_name.split("-"); for (i=0;i<form.elements.length;i++){ THATname = form.elements.name.split("-"); if (Sname.length==1){ if (THATname==Sname){
by: Walt Borders | last post by:
Hi, My problem: Merging two datasets deletes parent elements, preserves all children. I've created two dataSets. Each use the same schema, parent-child nested tables. The first dataSet is loaded with historical data read from an XML file. The second dataSet has current data filled from a dataGrid.
by: Nikhil Prashar | last post by:
I'm trying to merge two XML files that have the same structure but not necessarily the same nodes in the same order. I've tried opening the files as datasets and using the DataSet.Merge() function, but this only "fumbles" the data together and puts children under the wrong parent nodes. How else could I go about merging the files? I'm using C# .NET.
by: Dan Cooper | last post by:
I've got two datasets, each containing a single data table. dstDataSetA.Tables("TableA") dstDataSetB.Tables("TableB") I want to merge them together and delete any non-matching rows. dstDataSetB.Merge(dstDataSetA) doesn't do this. Any ideas or suggestions gratefully received.
by: garethdjames | last post by:
For scalability we wish to use disconnected DataSets and hold them in the application cache. This means that multiple concurrent users will be reading the data (its read only) The DataSet is fairly complicated and contains many tables and many relationships What we would like to do is create a DataView that flattens the in
by: Jon Vaughan | last post by:
I have 2 datasets , one returned as a dataset from a webservice and one created client side form the same stored procedure that is returned from the webservice. I then try and merge the data, but they dont seem to merge. When I return a single table , this method works fine, but im returning 3 tables and the merge isnt happening. Is there anyway to find out how I can why a merge isnt occuring, as the merge doesnt return any errors,
by: cesar.guinovart | last post by:
I have the following table CREATE TABLE ( int IDENTITY(1,1) CONSTRAINT PK_tbl_Items__item_id PRIMARY KEY, int DEFAULT(NULL) CONSTRAINT FK_tbl_Items__item_id__parent_id REFERENCES ( ) ON DELETE NO ACTION ON UPDATE NO ACTION )
by: gardnern | last post by:
We have X number of data sets, of Y length each. For example... Small, Medium, Large and Red, Green, Blue, Yellow We need to generate a list of all possibilities Small Red
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
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 most users, this new feature is actually very convenient. If you want to control the update process,...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.