Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > ADO.NET
|
ADO.NET For discussion about ADO.NET.  Topics such as question regarding the System.Data namespace are appropriate.  Questions specific to a particular application should be posted in a forum specific to the application .
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ADO.NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 19th, 2005, 04:25 AM
Registered User
 
Join Date: Mar 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default problem using Dataset.WriteXml()

I have a problem getting Dataset.WriteXml() to create a nested xml
realtionship. All I get is an inline xsd (all nodes are children of
the root). Documentation says to use Dataset.Relations.Nested="true";
but this doesn't produce the nested xml as it should. I have even
used a unit test, "MessageBox.Show(Dataset.Relations.Nested.ToString ());".
I get the "True" as an answer. So, the ReationsCollection has a
relation and it is nested. Why then doesn't it work according to the
documentation. I have created this example using the Visual Designer
and coded it programmatically and both have the same results.


Below is the code that I am using...


cmd=new SqlCommand();
            cmd.Connection=conn;
            //cmd.CommandType=CommandType.StoredProcedure;
            cmd.CommandText="select * from customers";

            //cmd.Parameters.Add("@PNR_no", SqlDbType.VarChar);
            //cmd.Parameters["@PNR_no"].Value="DA00130247";
            da = new SqlDataAdapter(cmd);
            ds = new DataSet();

            ds.ReadXmlSchema(@"c:\Inetpub\wwwroot\proXMLApp\XM LFile1.xsd");

            string str=@"c:\test.xml";

            da.Fill(ds,"Customers");

            cmd.CommandText="select * from orders";
            da1 = new SqlDataAdapter(cmd);
            da1.Fill( ds,"Orders");

            //DataRelation drCust = ds.Relations.Add("Customers_Orders",ds.Tables["Customers"].Columns["Customer_Id"],ds.Tables["Orders"].Columns["Customer_Id"]);
            //drCust.Nested=true;

            ds.WriteXml(str)

The tables used i.e Customers and Orders have a linking field Customer_Id where Customers is the master table. I am using the xml schema(XMLFile1.xsd) file to achieve the same.

Thanks






Similar Threads
Thread Thread Starter Forum Replies Last Post
result from DataSet.WriteXml rachamim C# 2005 1 January 28th, 2008 12:52 PM
Data set writexml problem tasiekk ADO.NET 0 September 26th, 2006 04:38 AM
WriteXml standalone property mega ADO.NET 0 June 21st, 2006 09:14 AM
DataSet.WriteXML Problem jim.stanley ADO.NET 0 September 21st, 2004 12:27 PM
Missing Columns with WriteXml khautinh General .NET 0 August 20th, 2004 10:46 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.