Re: Saving dataset as nested XML
From: Paul Eden (a_at_b.com)
Date: 10/07/04
- Next message: Pipo: "Howto: Add XML Attributes to a dataset?"
- Previous message: olivier aka Cypher: "Re: Xml and Serialization."
- In reply to: Richard L Rosenheim: "Re: Saving dataset as nested XML"
- Next in thread: Richard L Rosenheim: "Re: Saving dataset as nested XML"
- Reply: Richard L Rosenheim: "Re: Saving dataset as nested XML"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 07 Oct 2004 17:55:20 GMT
Final installment (hopefully..)
Found the issue with the nesting on my work PC - for some reason
Windows Update had neglected to down load the Framework 1.1 SP1 (though
I thought it was on). One download later all is well - hope you get the
same results.
Paul
Richard L Rosenheim wrote:
> Those issues are just a load of fun to track down.
>
> I've been tied up with an unexpected project (which they wanted ASAP, of
> course) and I haven't had a chance to give it a try. Hopefully over the
> weekend I'll be able to get to it.
>
> Richard Rosenheim
>
>
> "Paul [Paradise Solutions]" <Paul@Don'tChuffingSpamMe.com> wrote in message
> news:ck17q5$qrm$1$8302bc10@news.demon.co.uk...
>
>>Same person, different posting location...
>>
>>I don't think this has gone away - worked great at home, but at work I
>
> get:
>
>>An unhandled exception of type 'System.Data.DuplicateNameException'
>>occurred in system.data.dll
>>
>>Additional information: A column named 'Barcodes' already belongs to
>>this DataTable: cannot set a nested table name to the same name.
>>
>>Exactly the same code that worked at home fails here.
>>
>>Both systems running Framework 1.1 +sp, Vs.Net2003 Ent Dev retail
>>
>>Work = XP and 2K server (server was justa convienient test machine)
>>Home = 2K Pro
>>
>>
>>Did the relationship suggestion work for you?
>>
>>
>>Paul
>>
>>
>>
>>
>>Paul Eden wrote:
>>
>>>Essentially, the schema creates 2 relations (in my case)
>>>
>>>Customers.Customer_ID --> Addresses.Customer_ID
>>>
>>>and
>>>
>>>Addresses.Addresses_ID --> Address.Addresses_ID
>>>
>>>The following code created my output as nested:
>>>
>>> With CustomerData
>>>
>>>.ReadXmlSchema(IO.Path.GetDirectoryName(Application.ExecutablePath) &
>>>"\Customer.xsd")
>>> .Relations.Clear()
>>> .Relations.Add("CustomerToAddresses",
>>>.Tables(0).Columns("CustomerID"), .Tables(1).Columns("CustomerID"))
>>> .Relations(0).Nested = True
>>>
>>> .Relations.Add("AddressesToAddress",
>>>.Tables(1).Columns("AddressesID"), .Tables(2).Columns("AddressesID"))
>>> .Relations(1).Nested = True
>>> End With
>>>
>>>
>>>
>>>
>>>Where CustomerID and AddressesID are my new additional fields.
>>>
>>>I also tried re-creating the relationships using the original fieldnames
>>>(with the '_', which are hidden fields) but once again my output was
>
> wrong.
>
>>>The code should paste driect into IDE without problems.
>>>
>>>
>>>Paul
>>>
>>>Richard L Rosenheim wrote:
>>>
>>>
>>>>Can you please provide more details of how you got it to work?
>>>>
>>>>I too have confirmed that the relationships are being created by
>
> checking
>
>>>>the Relations. My child tables, in additional to an unique autonumber
>
> ID
>
>>>>field, also contains an ID field containing the parent ID. All these
>>>>fields
>>>>are defined as of type "long". And, IsNested is defined as true in the
>>>>relation tags in the resulting XML Schema.
>>>>
>>>>Richard Rosenheim
>>>>
>>>>
>>>>"Paul Eden" <a@b.com> wrote in message
>>>>news:Xzg8d.202$y%3.31@newsfe1-win.ntli.net...
>>>>
>>>>
>>>>>Richard
>>>>>
>>>>>I been fidling with this for most of the day. My Schema, when loaded
>>>>>into the dataset, generates all the relevent relationships (this I did
>>>>>not realise, going on the lack of correct output), with nested set to
>>>>>true (via interogating the dataset).
>>>>>I finally too the step of clearing the Relations collection on the
>
> data
>
>>>>>set, and re-creating them manually (which was a bit of a bugger,
>>>>>becausae I had to go through and add ID fields for the
>
> relationships)...
>
>>>>>BUT.. my ouput is now nested.
>>>>>
>>>>>A long winded and painfull fix, but it's the only one I found - hope
>
> an
>
>>>>>MS bod is reading - would be interesting to hear thier side.
>>>>>
>>>>>
>>>>>Paul
>>>>>
>>>>>Richard L Rosenheim wrote:
>>>>>
>>>>>
>>>>>>You are correct -- having IsNested="true" doesn't seems to make any
>>>>>>difference what-so-ever. In the XML file that I attached to my
>>>>>>previous
>>>>>>post, it contained IsNested="true" attributes for the keys.
>>>>>>
>>>>>>Richard Rosenheim
>>>>>>
>>>>>>
>>>>>>
>>>>>>"Paul Eden" <a@b.com> wrote in message
>>>>>>news:0Rb8d.56$hs3.38@newsfe5-win.ntli.net...
>>>>>>
>>>>>>
>>>>>>
>>>>>>>Richard
>>>>>>>
>>>>>>>I'm having much the same issue. In one post I read that you have
>>>>>>>to set
>>>>>>>up the relationships in the dataset and have the relationship
>>>>>>>flaged as
>>>>>>>Nested=True, but this did not create the desired output either..
>>>>>>>actually, it made no difference whatsoever. It might make a
>>>>>>>difference
>>>>>>>for you?
>>>>>>>
>>>>>>>I can post my schema and code if required.
>>>>>>>
>>>>>>>
>>>>>>>Paul
>>>>>>>
>>>>>>>Richard L Rosenheim wrote:
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>>I've been trying to save a dataset to a XML file and have the child
>>>>
>>>>
>>>>data
>>>>
>>>>
>>>>>>>>nested under the parent data. Everything I have tried so far
>
> results
>
>>>>
>>>>in
>>>>
>>>>
>>>>>>all
>>>>>>
>>>>>>
>>>>>>
>>>>>>>>the records from the parent table being listed followed by all the
>>>>>>>>rows
>>>>>>
>>>>>>
>>>>>>of
>>>>>>
>>>>>>
>>>>>>
>>>>>>>>the child table.
>>>>>>>>
>>>>>>>>As a result of previous posts, I currently created my tables based
>>>>>>>>upon
>>>>>>
>>>>>>
>>>>>>the
>>>>>>
>>>>>>
>>>>>>
>>>>>>>>steps outlined in
>>>>>>>>
>>>>>>
>>>>>>
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbtskcreatingnestedrelationshipsinxmlschemas.asp
>
>>>>
>>>>>>>>For my example, I created three tables: Contacts, Telephones and
>>>>>>
>>>>>>
>>>>>>Addresses
>>>>>>
>>>>>>
>>>>>>
>>>>>>>>where Telephones and Addresses are defined as children of
>>>>>>>>Contacts. In
>>>>>>
>>>>>>
>>>>>>the
>>>>>>
>>>>>>
>>>>>>
>>>>>>>>resulting schema, Telephones and Addresses are nested within
>>>>>>>>Contacts.
>>>>>>
>>>>>>
>>>>>>But
>>>>>>
>>>>>>
>>>>>>
>>>>>>>>the actual data is not.
>>>>>>>>
>>>>>>>>What I'm looking to achieve is to have the data outputted in a
>
> format
>
>>>>>>
>>>>>>like:
>>>>>>
>>>>>>
>>>>>>
>>>>>>>> <Contacts>
>>>>>>>> <Addresses>
>>>>>>>> </Addresses>
>>>>>>>> <Telephones>
>>>>>>>> </Telephones>
>>>>>>>> <Telephones>
>>>>>>>> </Telephones>
>>>>>>>> </Contacts>
>>>>>>>>instead of the structure I'm getting:
>>>>>>>> <Contacts>
>>>>>>>> </Contacts>
>>>>>>>> <Contacts>
>>>>>>>> </Contacts>
>>>>>>>> <Addresses>
>>>>>>>> </Addresses>
>>>>>>>> <Telephones>
>>>>>>>> </Telephones>
>>>>>>>> <Telephones>
>>>>>>>> </Telephones>
>>>>>>>>
>>>>>>>>Anyone have any ideas? Attached is the resulting XML file I'm
>>>>>>>>getting,
>>>>>>
>>>>>>
>>>>>>with
>>>>>>
>>>>>>
>>>>>>
>>>>>>>>schema. I'm using Visual Studio 2003.
>>>>>>>>
>>>>>>>>TIA,
>>>>>>>>
>>>>>>>>Richard Rosenheim
>>>>>>>>
>>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>
>
>
- Next message: Pipo: "Howto: Add XML Attributes to a dataset?"
- Previous message: olivier aka Cypher: "Re: Xml and Serialization."
- In reply to: Richard L Rosenheim: "Re: Saving dataset as nested XML"
- Next in thread: Richard L Rosenheim: "Re: Saving dataset as nested XML"
- Reply: Richard L Rosenheim: "Re: Saving dataset as nested XML"
- Messages sorted by: [ date ] [ thread ]