Setting Up XML DB

  • Thread starter Thread starter Wayne Wengert
  • Start date Start date
W

Wayne Wengert

I am trying to build a VB.NET Windows application in which I want to create
an XML file from data collected from the user and stored in arrays. I am
looking for any pointers to information on how to accomplish this.

TIA

Wayne
 
One easy way is to load the data into a datatable instead of arrays, or use
the arrays to load a datatable. Put the datatable in a dataset and use the
..WriteXML method to write it and DataSet.ReadXML to read it.

You can also make your Arrays memebers of a class and mark the class as
Serializable and use the serialization libraries to accomplish this.

HTH,

Bill
 
William;

Thanks for the reply. Do you have a pointer to information or examples of
how to accomplish this? I am feeling like it is a catch 22 since the only
way I see to get a datatable is to have a dataset to contain it but I have
not yet created the dataset. I am unsure of how to accomplish this.

Wayne
 
Hi Wayne:

What part do you need? I'll try to find something in particular.

if you have a datatab;le, the rest is easy:

DataSet ds = new DataSet();
ds.Tables.Add(DataTableYouCretaed);
ds.WriteXML(@"Path:\Fielname.xml");

then, set up a dataadapter and just call update
dataAdapter1.Update(ds.Tables[0]) //you may need multiple adapters depending
on how many tables you have.

HTH,

Bill
 
Thanks for the help here. I know I am confused on procedures and terms for
all this. Basically, I want to end up with an XML file similar to the one
shown below. I currently have 2 arrays - one with just the common show data
(showname and showdate) and another array with sets of values for each entry
(name, team, event, time).

From what I've read I believe I want to create a new datatable for each of
those 2 current arrays and define columns as appropriate? But since the
contest data table will have just one row and the entries table will have
many rows I don't see how to build an object from which I can export the XML
I need. I've though of a cross join (right term?) where the output will
consist of rows where the contest data is repeated in each row. That seems
inefficient?

Any pointers are much appreciated

================================================

<contest>
<contestinfo>
<contestname>South Side Contest</contestname>
<contestdate>2004-05-07</contestdate>
</contestinfo>
<entry>
<name>Johnny Jones</name>
<team>Marauders</team>
<event>Relay Race</event>
<time>10:30 AM</time>
</entry>
<entry>
<name>Mary Smith</name>
<team>Marauders</team>
<event>Relay Race</event>
<time>10:30 AM</time>
</entry>
<entry>
<name>Ed Brown</name>
<team>Hot Shots</team>
<event>200 Yd</event>
<time>10:45 AM</time>
</entry>
<entry>
<name>Jack Green</name>
<team>Marauders</team>
<event>200 Yd</event>
<time>10:45 AM</time>
</entry>
</contest>
=============================================

Wayne

William Ryan eMVP said:
Hi Wayne:

What part do you need? I'll try to find something in particular.

if you have a datatab;le, the rest is easy:

DataSet ds = new DataSet();
ds.Tables.Add(DataTableYouCretaed);
ds.WriteXML(@"Path:\Fielname.xml");

then, set up a dataadapter and just call update
dataAdapter1.Update(ds.Tables[0]) //you may need multiple adapters depending
on how many tables you have.

HTH,

Bill
Wayne Wengert said:
William;

Thanks for the reply. Do you have a pointer to information or examples of
how to accomplish this? I am feeling like it is a catch 22 since the only
way I see to get a datatable is to have a dataset to contain it but I have
not yet created the dataset. I am unsure of how to accomplish this.

Wayne

or
use use
the
I
 
I just loaded your xml into a dataset and got two tables as expected. In
your dataset or object, you need a link between the two, there doesn't
appear to be one. If one value is common in both tables, then you can use a
DataRelation and the rest is really easy, I can walk you through it in a few
minutes. However, do I understand the structure correctly in that there is
some sort of relationship between the two, some link between the two
tables.?
Wayne Wengert said:
Thanks for the help here. I know I am confused on procedures and terms for
all this. Basically, I want to end up with an XML file similar to the one
shown below. I currently have 2 arrays - one with just the common show data
(showname and showdate) and another array with sets of values for each entry
(name, team, event, time).

From what I've read I believe I want to create a new datatable for each of
those 2 current arrays and define columns as appropriate? But since the
contest data table will have just one row and the entries table will have
many rows I don't see how to build an object from which I can export the XML
I need. I've though of a cross join (right term?) where the output will
consist of rows where the contest data is repeated in each row. That seems
inefficient?

Any pointers are much appreciated

================================================

<contest>
<contestinfo>
<contestname>South Side Contest</contestname>
<contestdate>2004-05-07</contestdate>
</contestinfo>
<entry>
<name>Johnny Jones</name>
<team>Marauders</team>
<event>Relay Race</event>
<time>10:30 AM</time>
</entry>
<entry>
<name>Mary Smith</name>
<team>Marauders</team>
<event>Relay Race</event>
<time>10:30 AM</time>
</entry>
<entry>
<name>Ed Brown</name>
<team>Hot Shots</team>
<event>200 Yd</event>
<time>10:45 AM</time>
</entry>
<entry>
<name>Jack Green</name>
<team>Marauders</team>
<event>200 Yd</event>
<time>10:45 AM</time>
</entry>
</contest>
=============================================

Wayne

William Ryan eMVP said:
Hi Wayne:

What part do you need? I'll try to find something in particular.

if you have a datatab;le, the rest is easy:

DataSet ds = new DataSet();
ds.Tables.Add(DataTableYouCretaed);
ds.WriteXML(@"Path:\Fielname.xml");

then, set up a dataadapter and just call update
dataAdapter1.Update(ds.Tables[0]) //you may need multiple adapters depending
on how many tables you have.

HTH,

Bill
Wayne Wengert said:
William;

Thanks for the reply. Do you have a pointer to information or examples of
how to accomplish this? I am feeling like it is a catch 22 since the only
way I see to get a datatable is to have a dataset to contain it but I have
not yet created the dataset. I am unsure of how to accomplish this.

Wayne

One easy way is to load the data into a datatable instead of arrays, or
use
the arrays to load a datatable. Put the datatable in a dataset and use
the
.WriteXML method to write it and DataSet.ReadXML to read it.

You can also make your Arrays memebers of a class and mark the class as
Serializable and use the serialization libraries to accomplish this.

HTH,

Bill
I am trying to build a VB.NET Windows application in which I want to
create
an XML file from data collected from the user and stored in
arrays.
 
Thanks for the continued education.

When you say you loaded my XML into a dataset, exactly how did you do that?

As for the tables, there is no link - I can easily give each show data entry
an identity value ("ShowID") and then use that as a link in the entries
table.

Wayne


William Ryan eMVP said:
I just loaded your xml into a dataset and got two tables as expected. In
your dataset or object, you need a link between the two, there doesn't
appear to be one. If one value is common in both tables, then you can use a
DataRelation and the rest is really easy, I can walk you through it in a few
minutes. However, do I understand the structure correctly in that there is
some sort of relationship between the two, some link between the two
tables.?
Wayne Wengert said:
Thanks for the help here. I know I am confused on procedures and terms for
all this. Basically, I want to end up with an XML file similar to the one
shown below. I currently have 2 arrays - one with just the common show data
(showname and showdate) and another array with sets of values for each entry
(name, team, event, time).

From what I've read I believe I want to create a new datatable for each of
those 2 current arrays and define columns as appropriate? But since the
contest data table will have just one row and the entries table will have
many rows I don't see how to build an object from which I can export the XML
I need. I've though of a cross join (right term?) where the output will
consist of rows where the contest data is repeated in each row. That seems
inefficient?

Any pointers are much appreciated

================================================

<contest>
<contestinfo>
<contestname>South Side Contest</contestname>
<contestdate>2004-05-07</contestdate>
</contestinfo>
<entry>
<name>Johnny Jones</name>
<team>Marauders</team>
<event>Relay Race</event>
<time>10:30 AM</time>
</entry>
<entry>
<name>Mary Smith</name>
<team>Marauders</team>
<event>Relay Race</event>
<time>10:30 AM</time>
</entry>
<entry>
<name>Ed Brown</name>
<team>Hot Shots</team>
<event>200 Yd</event>
<time>10:45 AM</time>
</entry>
<entry>
<name>Jack Green</name>
<team>Marauders</team>
<event>200 Yd</event>
<time>10:45 AM</time>
</entry>
</contest>
=============================================

Wayne

William Ryan eMVP said:
Hi Wayne:

What part do you need? I'll try to find something in particular.

if you have a datatab;le, the rest is easy:

DataSet ds = new DataSet();
ds.Tables.Add(DataTableYouCretaed);
ds.WriteXML(@"Path:\Fielname.xml");

then, set up a dataadapter and just call update
dataAdapter1.Update(ds.Tables[0]) //you may need multiple adapters depending
on how many tables you have.

HTH,

Bill
William;

Thanks for the reply. Do you have a pointer to information or
examples
of
how to accomplish this? I am feeling like it is a catch 22 since the only
way I see to get a datatable is to have a dataset to contain it but
I
have
not yet created the dataset. I am unsure of how to accomplish this.

Wayne

One easy way is to load the data into a datatable instead of
arrays,
or
use
the arrays to load a datatable. Put the datatable in a dataset
and
use
the
.WriteXML method to write it and DataSet.ReadXML to read it.

You can also make your Arrays memebers of a class and mark the
class
as
Serializable and use the serialization libraries to accomplish this.

HTH,

Bill
I am trying to build a VB.NET Windows application in which I
want
to arrays.
 
myDataSet.ReadXML(@"Path:\File.xml");

THis may aslo be helpful
http://www.knowdotnet.com/articles/datarelation.html
Wayne Wengert said:
Thanks for the continued education.

When you say you loaded my XML into a dataset, exactly how did you do that?

As for the tables, there is no link - I can easily give each show data entry
an identity value ("ShowID") and then use that as a link in the entries
table.

Wayne


William Ryan eMVP said:
I just loaded your xml into a dataset and got two tables as expected. In
your dataset or object, you need a link between the two, there doesn't
appear to be one. If one value is common in both tables, then you can
use
a
DataRelation and the rest is really easy, I can walk you through it in a few
minutes. However, do I understand the structure correctly in that there is
some sort of relationship between the two, some link between the two
tables.?
each
of
those 2 current arrays and define columns as appropriate? But since the
contest data table will have just one row and the entries table will have
many rows I don't see how to build an object from which I can export
the
XML
I need. I've though of a cross join (right term?) where the output will
consist of rows where the contest data is repeated in each row. That seems
inefficient?

Any pointers are much appreciated

================================================

<contest>
<contestinfo>
<contestname>South Side Contest</contestname>
<contestdate>2004-05-07</contestdate>
</contestinfo>
<entry>
<name>Johnny Jones</name>
<team>Marauders</team>
<event>Relay Race</event>
<time>10:30 AM</time>
</entry>
<entry>
<name>Mary Smith</name>
<team>Marauders</team>
<event>Relay Race</event>
<time>10:30 AM</time>
</entry>
<entry>
<name>Ed Brown</name>
<team>Hot Shots</team>
<event>200 Yd</event>
<time>10:45 AM</time>
</entry>
<entry>
<name>Jack Green</name>
<team>Marauders</team>
<event>200 Yd</event>
<time>10:45 AM</time>
</entry>
</contest>
=============================================

Wayne

Hi Wayne:

What part do you need? I'll try to find something in particular.

if you have a datatab;le, the rest is easy:

DataSet ds = new DataSet();
ds.Tables.Add(DataTableYouCretaed);
ds.WriteXML(@"Path:\Fielname.xml");

then, set up a dataadapter and just call update
dataAdapter1.Update(ds.Tables[0]) //you may need multiple adapters
depending
on how many tables you have.

HTH,

Bill
William;

Thanks for the reply. Do you have a pointer to information or examples
of
how to accomplish this? I am feeling like it is a catch 22 since the
only
way I see to get a datatable is to have a dataset to contain it
but
 
William;

I changed the XML code to include the relations (I hope) and that new file
is below. I am still having trouble working with the file. I took your
sample for reading the XML data into a dataset but I still am confused about
exactly what needs to be done to get to the data. I have the following code
(VB) but I don't see how to bind the data to the grid - Intellisense does
not show "DataBind" as a method.

========================== Code =============================
' Instantiate the DataSet variable.

Dim dsImportXML As DataSet

dsImportXML = New DataSet

dsImportXML.ReadXml("c:\temp\contest.xml")

DataGrid1.DataSource = dsImportXML.Tables(0)

==> Want to Bind here <==

=============================================================

======================= XML File ==============================
<?xml version="1.0" encoding="utf-8" ?>

<!-- Test for Contest File -->
<contest>
<contestinfo contestid="005">
<contestname>South Side Contest</contestname>
<contestdate>2004-05-07</contestdate>
</contestinfo>
<entry contestid="005">
<name>Johnny Jones</name>
<team>Marauders</team>
<event>Relay Race</event>
<time>10:30 AM</time>
</entry>
<entry contestid="005">
<name>Mary Smith</name>
<team>Marauders</team>
<event>Relay Race</event>
<time>10:30 AM</time>
</entry>
<entry contestid="005">
<name>Ed Brown</name>
<team>Hot Shots</team>
<event>200 Yd</event>
<time>10:45 AM</time>
</entry>
<entry contestid="005">
<name>Jack Green</name>
<team>Marauders</team>
<event>200 Yd</event>
<time>10:45 AM</time>
</entry>
</contest>
=============================================================

Wayne


William Ryan eMVP said:
myDataSet.ReadXML(@"Path:\File.xml");

THis may aslo be helpful
http://www.knowdotnet.com/articles/datarelation.html
Wayne Wengert said:
Thanks for the continued education.

When you say you loaded my XML into a dataset, exactly how did you do that?

As for the tables, there is no link - I can easily give each show data entry
an identity value ("ShowID") and then use that as a link in the entries
table.

Wayne


use a
few
there
is
some sort of relationship between the two, some link between the two
tables.?
Thanks for the help here. I know I am confused on procedures and
terms
for
all this. Basically, I want to end up with an XML file similar to
the
one
shown below. I currently have 2 arrays - one with just the common show
data
(showname and showdate) and another array with sets of values for each
entry
(name, team, event, time).

From what I've read I believe I want to create a new datatable for
each
of
those 2 current arrays and define columns as appropriate? But since the
contest data table will have just one row and the entries table will have
many rows I don't see how to build an object from which I can export the
XML
I need. I've though of a cross join (right term?) where the output will
consist of rows where the contest data is repeated in each row. That seems
inefficient?

Any pointers are much appreciated

================================================

<contest>
<contestinfo>
<contestname>South Side Contest</contestname>
<contestdate>2004-05-07</contestdate>
</contestinfo>
<entry>
<name>Johnny Jones</name>
<team>Marauders</team>
<event>Relay Race</event>
<time>10:30 AM</time>
</entry>
<entry>
<name>Mary Smith</name>
<team>Marauders</team>
<event>Relay Race</event>
<time>10:30 AM</time>
</entry>
<entry>
<name>Ed Brown</name>
<team>Hot Shots</team>
<event>200 Yd</event>
<time>10:45 AM</time>
</entry>
<entry>
<name>Jack Green</name>
<team>Marauders</team>
<event>200 Yd</event>
<time>10:45 AM</time>
</entry>
</contest>
=============================================

Wayne

Hi Wayne:

What part do you need? I'll try to find something in particular.

if you have a datatab;le, the rest is easy:

DataSet ds = new DataSet();
ds.Tables.Add(DataTableYouCretaed);
ds.WriteXML(@"Path:\Fielname.xml");

then, set up a dataadapter and just call update
dataAdapter1.Update(ds.Tables[0]) //you may need multiple adapters
depending
on how many tables you have.

HTH,

Bill
William;

Thanks for the reply. Do you have a pointer to information or examples
of
how to accomplish this? I am feeling like it is a catch 22 since the
only
way I see to get a datatable is to have a dataset to contain it
but
I
have
not yet created the dataset. I am unsure of how to accomplish this.

Wayne

One easy way is to load the data into a datatable instead of arrays,
or
use
the arrays to load a datatable. Put the datatable in a
dataset
and
use
the
.WriteXML method to write it and DataSet.ReadXML to read it.

You can also make your Arrays memebers of a class and mark the class
as
Serializable and use the serialization libraries to accomplish this.

HTH,

Bill
I am trying to build a VB.NET Windows application in which I want
to
create
an XML file from data collected from the user and stored in
arrays.
I
am
looking for any pointers to information on how to accomplish this.

TIA

Wayne
 
Back
Top