0
Reply

How do I create a data table that contains an array? VB.Net

Thomas

Thomas

Feb 19 2010 6:49 PM
2.5k


I have a database record that i am saving to an XML file and then stuffing it into a dataset and viewing in a datagrid.  If my record contains an array with 20 fields, i.e. Child(20), How do I create a dataset to handle the array?  You can't have a data table with more than one column named the same and I think that there is a better way than renaming "Child" to something like "Child_1", "Child_2" etc.  Should "Child" be put into a seperate table and joined?  I am using strictly VB.NET.  Any thoughts, direction or help is very much appreciated!!!
This has got to happen often but I can't find any information on how other people handle this situation.
Below is an example in XML format of what I'm trying to do.  It's easy to do in XML and with my database.  How does/should it work in ADO.NET?
<ParentTable>
    <Age>30</Age>
    <Sex>M</Sex>
    <Married>Y</Married>
    <Child>
      <Age>10</Age>
      <Sex>M</Sex>
      <Comments />
    </Child>

    <Child>
      <Age>8</Age>
      <Sex>M</Sex>
      <Comments />
    </Child>

    <Child>
      <Age>6</Age>
      <Sex>M</Sex>
      <Comments />
    </Child>

    <Child>
      <Age>14</Age>
      <Sex>F</Sex>
      <Comments />
    </Child>

</ParentTable>