473,473 Members | 1,790 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to change the sequence of the Nested DataRelation XML elements/attributes

Thu
Hi,
I create a Dataset to link three tables in my Access
database. E.g. The three tables are [Order], [Customer],
[Product]. I then create 2 DataRelations, 1st relation
(Order_Cust_Rel) links [Order] and [Customer] using
CustomerID field that exists in both tables and 2nd
relation (Order_Product_Rel) links [Order] and [Product]
using ProductID field. I set the nested property of the
relations to True so that the output will be nested. I
then use WriteXML to output the dataset to a StreamWriter.

Please see the code below:

Imports System.Data
Imports System.Data.OleDb
Imports System.Xml
Imports System.IO

Private Sub WriteXMLToFile()

Dim conn As OleDbConnection = New OleDbConnection
("Provider=Microsoft.Jet.OLEDB.4.0; Data
source=C:\Sales.mdb")
Dim OrderDA As OleDbDataAdapter = New OleDbDataAdapter
("SELECT * FROM [Order]", conn)
Dim CustomerDA As OleDbDataAdapter = New
OleDbDataAdapter("SELECT * FROM [Customer]", conn)
Dim ProductDA As OleDbDataAdapter = New
OleDbDataAdapter("SELECT * FROM [Product]", conn)
Dim DS As DataSet = New DataSet("SalesOrder")

OrderDA.Fill(DS, "Order")
CustomerDA.Fill(DS, "Customer")
ProductDA.Fill(DS, "Product")

Dim Order_Cust_Rel As DataRelation =
DS.Relations.Add("OrderCust", DS.Tables("Order").Columns
("CustomerID"), DS.Tables("Customer").Columns
("CustomerID"))
Order_Cust_Rel.Nested = True

Dim Order_Product_Rel As DataRelation =
DS.Relations.Add("OrderProduct", DS.Tables
("Order").Columns("ProductID"), DS.Tables
("Product").Columns("ProductID"))
Order_Product_Rel.Nested = True

Dim filename As String = "c:\XmlFile.xml"

Dim xmlSW As StreamWriter = New StreamWriter
(filename, True)

DS.WriteXml(xmlSW)

End Sub
By default, the three tables data will be output one
after another, that is [Order], follow by [Customer],
follow by [Product]. As below:

<SalesOrder>
<Order>
<OrderID>1001</OrderID>
<OrderDate>2003-11-10</OrderDate>
<CustomerID>10250</CustomerID>
<ProductID>SE-071-001</ProductID>
<Qty>100</Qty>
<DeliverDate>2003-12-15</DeliverDate>
<Customer>
<CustomerID>10250</CustomerID>
<Name>CreaInnov Inc.</Name>
</Customer>
<Product>
<ProductID>SE-071-001</ProductID>
<ProductName>Secure Email Gateway</ProductName>
<UnitPrice>2700</UnitPrice>
</Product>
</Order>
</SalesOrder>
However, I need the [Customer] and [Product] tables to
appear in the middle of [Order] table. I.e. When [Order]
table links with [Customer] table using CustomerID, I
need the Customer table fields appear right after the
CustomerID field, and so for Product table. I also need
to hide those linking fields, i.e. CustomerID,
ProductID . I have to follow this format as this is
required by the vendor.

<SalesOrder>
<Order>
<OrderID>1001</OrderID>
<OrderDate>2003-11-10</OrderDate>
<Customer>
<Name>CreaInnov Inc.</Name>
</Customer>
<Product>
<ProductName>Secure Email Gateway</ProductName>
<UnitPrice>2700</UnitPrice>
</Product>
<Qty>100</Qty>
<DeliverDate>2003-12-15</DeliverDate>
</Order>
</SalesOrder>
Can anyone let me know how to achieve this? Do I use XSD
schema or Mapping machanism to do this, or ?? Please
help.. thanks.

Nov 20 '05 #1
1 2053
Cor
Hi Thu,

This is typical a question for the

public.dotnet.framework.ADO.NET newsgroup.

I think they will give you one select statement but I am not sure of it, I
would try it there also.

Cor
Nov 20 '05 #2

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

Similar topics

8
by: Ike | last post by:
I am hoping someone can help me with the proper syntax for this. I have an attribute, called, say "name," such that: <set name="something">thename</set> However, the value for name, is...
9
by: Dr John Stockton | last post by:
Assuming default set-ups and considering all reasonable browsers, whatever that may mean, what should an author expect that his readers in general will see (with visual browsers) for a page with...
0
by: Thu | last post by:
Can anyone help me please.. I am using vb.net to WriteXML from Ms Access tables to an output stream. Basically, I retrieve data from 3 tables then use DataRelations to link these three tables,...
2
by: Isz | last post by:
Hi Group: I would like to know if it is possible to change the name of an attribute to something else. My setup is like this: I have serveral SQL tables that I nest and join so that it all...
2
by: Daniel Lidström | last post by:
Hi, I would like to know the cleanest way to change the serialization of my Line class from: <Line staStart="2327.02" length="10.00000003390744"> <End>549016.570965 57945.741122</End>...
5
by: BMeyer | last post by:
I have been losing my mind trying to parse an XML document (with nested child elements, not all of which appear in each parent node) into a DataGrid object. What I want to do is "flatten" the XML...
0
by: jts2077 | last post by:
I am trying to create a large nested XML object using E4X methods. The problem is the, the XML I am trying to create can only have xmlns set at the top 2 element levels. Such as: <store ...
0
by: KA NMC | last post by:
I have One Datagrid with a dataset that calls two tables - the First table is the table the user will be editing - which edited on the grid or in a textbox - as the user edits the grid - that info is...
2
by: Me LK | last post by:
I have a set of drop downs nested in a datagrid. Each drop down is a size or color for an item. Each row of the grid has a button which leads to a cart. When a user selects something from the...
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...
1
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
agi2029
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,...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.