473,411 Members | 2,230 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,411 software developers and data experts.

Populate and Merge DataSet to form an XML

Hi,

I need to populate and merge DataSet to make an XML in the following format:

<?xml version="1.0" standalone="yes"?>
<CompanyOrders>
<CompanyProfile>
<CompanyID>Test</CompanyID>
<CompanyName>The Company</CompanyName>
</CompanyProfile>
<OrderInformation>
<BuyerInformation>
<OrderNo>00001</OrderNo>
</BuyerInformation>
</OrderInformation>
</CompanyOrders>

So far I am able to come up with this code:

DataSet dsCompanyOrders = new DataSet("CompanyOrders");
DataTable dt = dsCompanyOrders.Tables.Add("CompanyProfile");
DataColumn dcCompanyID = new DataColumn("CompanyID");
DataColumn dcCompanyName = new DataColumn("CompanyName");
dt.Columns.AddRange(new DataColumn[]
{
dcCompanyID,dcCompanyName
}
);
DataRow drCompanyProfile = dt.NewRow();
drCompanyProfile["CompanyID"] = "Test";
drCompanyProfile["CompanyName"] = "The Company";
dt.Rows.Add(drCompanyProfile);

DataSet dsOrderInformation = new DataSet("OrderInformation");
DataTable dtBuyerInformation =
dsOrderInformation.Tables.Add("BuyerInformation");
DataColumn dcOrderNo = new DataColumn("OrderNo");
dtBuyerInformation.Columns.Add(dcOrderNo);
DataRow drOrderInformation = dtBuyerInformation.NewRow();
drOrderInformation["OrderNO"] = "00001";
dtBuyerInformation.Rows.Add(drOrderInformation);
dsCompanyOrders.Merge(dsOrderInformation,false,Mis singSchemaAction.Add);

dsCompanyOrders.WriteXml("c:\\test.xml",XmlWriteMo de.IgnoreSchema);

The problem is that I cant create the parent node <OrderInformation> and the
XML that is created is as follows:

<?xml version="1.0" standalone="yes"?>
<CompanyOrders>
<CompanyProfile>
<CompanyID>Test</CompanyID>
<CompanyName>The Company</CompanyName>
</CompanyProfile>
<BuyerInformation>
<OrderNo>00001</OrderNo>
</BuyerInformation>
</CompanyOrders>

Need some help with this :S

Thanks, Nauman.
Nov 16 '05 #1
0 1029

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

Similar topics

3
by: Li Weng | last post by:
Hi, I have an original dataset. It is copied to 2 different forms. Each form adds a new row to the same table in that dataset. When I merge these 2 dataset back to original one, the 2 new rows...
4
by: John Smith | last post by:
..Net 2003 C# I get xml from a sql database pull. I put the data into a XMLDomDocument and then the user changes it. I now need to update the database correctly. I need to be able to get the data...
7
by: Sharon | last post by:
I have successfully loaded a DataSet object with a XML schema (XSD). Now I wish to populate the tables that was created in the DataSet. I have an XML file/string that contain all the needed data...
3
by: Yul | last post by:
Hi, We are in the process of designing an ASP.NET app, where a user will enter some 'Customer ID' to be queried in the database. If the ID is valid, several stored procedures will be called to...
2
by: Mike Stephens | last post by:
A contact management application we previously developed for a customer now has a requirement to perform mail merging. Normally request like this would be very simple to solve, we were just point...
2
by: muntyanu | last post by:
Hi all, I have problem when merging existing DataTable into new dataset. DataSet ds = new DataSet(); while ( done ) { // fill myCustomDataSet.MyTable with data ds.Merge(...
0
by: Allen | last post by:
We converted our app from 1.1 to 2 and some code was no longer working. The case: From a non typed datatable, convert it to a typed one. How to reproduce the bug: -------------------------------...
5
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...
1
by: joproulx | last post by:
Hello all, Here is my problem: I am trying to merge 2 datasets but I don't want to overwrite rows that are already modified in my working dataset. Example: I have one Dataset with only one...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
Oralloy
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,...
0
jinu1996
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...
0
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...
0
tracyyun
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...

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.