|
-
May 27th, 2004, 10:54 PM
#1
Thread Starter
Hyperactive Member
XML/Dataset Help
Hello Peeps..
I have a bit of a problem, maybe someone can help me out.. I have a class that has an array list in it.. and the objects I stick in the arraylist also have array lists in them as well. When a user logs into my system and creates a account.. I have a bit of a tree setup as so..
AccountData
\
Character Data (Array List that can hold 8 characters per acct)
\
Character Inventory (Inventory for the selected character)
Now what I am doing is serializing the whole AccountData class to XML format. That works fine.. But from there I go to read the XML file into a Dataset so I can display the data in a datagrid and I get the following error..
An unhandled exception of type 'System.ArgumentException' occurred in system.data.dll
Additional information: The table (CharInv) cannot be the child table to itself in nested relations.
Now if I comment out the Character inventory, it will take one level of nesting from the AccountData class with a ArrayList in it filled with Characters, but each character has to have an array list in it as well..
As I said, it is written to xml fine from the serializer..
Code:
<?xml version="1.0" ?>
- <clsAcctData xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<AcctName>Wuzzbent</AcctName>
<AcctPass>My$ecret</AcctPass>
<AcctMail>[email protected]</AcctMail>
- <CharData>
- <anyType xsi:type="clsCharData">
<CharName>John Boy</CharName>
<CharGender>Male</CharGender>
- <CharInv>
- <anyType xsi:type="clsGameObj">
<oName>A Game Object</oName>
<oDesc>A new bouncing baby game object.</oDesc>
</anyType>
</CharInv>
</anyType>
</CharData>
</clsAcctData>
Now why wont a Dataset be able to read this, is there something special I have to do?
-
May 27th, 2004, 11:26 PM
#2
XML is by nature heirarchy related but a DataTable is flat. You would need to translate the Heirarchy structure into a flat one using indexes that refer to other items in the table or tables.
-
May 28th, 2004, 08:09 AM
#3
Hyperactive Member
Tho it would be useful to see the code you are using to populate your dataset from the XML, at first glance it appears as tho your datarelations are incorrect for your dataset.
Based on the text of the exception, Your CharInv table cannot be a child to itself, it must have some other datatable in your dataset as a parent.
I am guessing that you are expecting the parent table to be the CharData table, but this must be established in your datarelations for the dataset.
I hope this isn't confusing you, it seems perfectly clear to me
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|