Groups | Blog | Home
all groups > dotnet general > december 2004 >

dotnet general : Typed Dataset issue



william
12/5/2004 8:45:02 PM
Hi,
I was using Typed Dataset in VB.NET to generate XML file.
I difined XSD file( named customer_order_info) to include three tables,
let's say customers, orders and order_details. I also defined relationship
between customers and orders, orders and order_details.( customerid is PK in
customers, orderid is PK in orders, orderid and productid are PK in
order_details).
In my VB.NET code, I declared a variable as the XSD(customer_order_info),
declared a adapter to populate it(some common routines to get dataset). the
select command is a stored procedure which will retuen 3 recordsets. I also
defined table mappings when I populated the dataset. After I got the dataset,
I call ds.getXML to get xml file. I was able to get the file with correct
content, but the format is wrong. For eample, the format should be as follows:
<customer customerid=”aaa” name=”bill” phone=”123345456” >
<order orderid=”1011” customerid=”aaa” shipname=”Du monde entire”>
<order_detail orderid=”1011” productid=”tool1” quantity=”12”/>
<order_detail orderid=”1011” productid=”tool2” quantity=”20”/>
<order_detail orderid=”1011” productid=”tool3” quantity=”30”/>
</order>
<order orderid=”1012” customerid=”aaa” shipname=”Du monde entire”>
<order_detail orderid=”1012” productid=”tool4” quantity=”12”/>
<order_detail orderid=”1012” productid=”tool2” quantity=”20”/>
<order_detail orderid=”1012” productid=”tool5” quantity=”30”/>
</order>
</customer>

But I got :
<customer customerid=”aaa” name=”bill” phone=”123345456” >
<order orderid=”1011” customerid=”aaa” shipname=”Du monde entire”/>
<order orderid=”1012” customerid=”aaa” shipname=”Du monde entire”/>
<order_detail orderid=”1011” productid=”tool1” quantity=”12”/>
<order_detail orderid=”1011” productid=”tool2” quantity=”20”/>
<order_detail orderid=”1011” productid=”tool3” quantity=”30”/>
<order_detail orderid=”1012” productid=”tool4” quantity=”12”/>
<order_detail orderid=”1012” productid=”tool2” quantity=”20”/>
<order_detail orderid=”1012” productid=”tool5” quantity=”30”/>
</customer>

Could anyone help me out?
Thanks.


Uri Dor
12/7/2004 10:54:36 AM
you assumed that the dataset will serialize the records based on some
relation between the tables - well, it doesn't. It serializes the
dataset one table after another (and will even support loading an XML in
which records from different tables are mixed, I suspect)

[quoted text, click to view]
AddThis Social Bookmark Button