Greetings,

I would like to know please how can I create two xml files from one
dataset with two tables in it? The WriteXML method of the DataSet
creates one XML file with BOTH tables of the dataset.


Dim ds as new dataset
Dim da as new dataadapter

'code goes here for declaration and database connection

da.fill(ds,"table1")
da.fill(ds,"table2")

ds.WriteXML(C:\text.xml) 'this will create ONE XML file...problem! I
need TWO

MTIA,
Grawsha

Re: One DS, two tables and two XML files? by Miha

Miha
Thu Dec 04 03:46:17 CST 2003

Hi al,

Already answered few days ago....

--
Miha Markic - RightHand .NET consulting & software development
miha at rthand com

"al" <grawsha2000@yahoo.com> wrote in message
news:66edfd3c.0312040047.5d468937@posting.google.com...
> Greetings,
>
> I would like to know please how can I create two xml files from one
> dataset with two tables in it? The WriteXML method of the DataSet
> creates one XML file with BOTH tables of the dataset.
>
>
> Dim ds as new dataset
> Dim da as new dataadapter
>
> 'code goes here for declaration and database connection
>
> da.fill(ds,"table1")
> da.fill(ds,"table2")
>
> ds.WriteXML(C:\text.xml) 'this will create ONE XML file...problem! I
> need TWO
>
> MTIA,
> Grawsha



Re: One DS, two tables and two XML files? by Kalpesh

Kalpesh
Thu Dec 04 05:28:47 CST 2003

Check out if this helps

Since you have both the tables inside a single dataset & you want to create 2 seperate xml file (each for a table)

// this will write xml for table 1
DataTable dt2 = ds.Tables("Table2")
ds.Tables.Remove(dt2);

ds.Writexml("c:\table1.xml");

// after this is done, add table2 & remove table1
ds.Tables.Add(dt2);

DataTable dt1 = ds.Tables("Table1")
ds.Tables.Remove(dt1);

ds.Writexml("c:\table2.xml");

// after both the things are done, add back table1
ds.Tables.Add(dt1);

HTH :-)
Kalpesh




Re: One DS, two tables and two XML files? by grawsha2000

grawsha2000
Thu Dec 04 18:03:03 CST 2003

Kalpesh Shah <kalpesh@disc.microsoft.com> wrote in message news:<O9nHzTluDHA.3196@TK2MSFTNGP11.phx.gbl>...
> Check out if this helps
>
> Since you have both the tables inside a single dataset & you want to create 2 seperate xml file (each for a table)
>
> // this will write xml for table 1
> DataTable dt2 = ds.Tables("Table2")
> ds.Tables.Remove(dt2);
>
> ds.Writexml("c:\table1.xml");
>
> // after this is done, add table2 & remove table1
> ds.Tables.Add(dt2);
>
> DataTable dt1 = ds.Tables("Table1")
> ds.Tables.Remove(dt1);
>
> ds.Writexml("c:\table2.xml");
>
> // after both the things are done, add back table1
> ds.Tables.Add(dt1);
>
> HTH :-)
> Kalpesh

Kalpesh,

Thanks for your help. The problem I see with your solution is that
there is an open form bound to that dataset at the moment of XML
writing. That is, when I remove Table2 from dataset, the data bound to
the form will disappear too. I guess I will just create two datasets.

Grawsha

Re: One DS, two tables and two XML files? by Miha

Miha
Fri Dec 05 03:21:18 CST 2003

Hi,

In that case you might want to copy dataset (see DataSet.Copy() method) and
manipulate on the copy.

--
Miha Markic - DXSquad/RightHand .NET consulting & software development
miha at rthand com

Developer Express newsgroups are for peer-to-peer support.
For direct support from Developer Express, write to support@devexpress.com
Bug reports should be directed to: support@devexpress.com
Due to newsgroup guidelines, DX-Squad will not answer anonymous postings.

"al" <grawsha2000@yahoo.com> wrote in message
news:66edfd3c.0312041603.5b65d34c@posting.google.com...
> Kalpesh Shah <kalpesh@disc.microsoft.com> wrote in message
news:<O9nHzTluDHA.3196@TK2MSFTNGP11.phx.gbl>...
> > Check out if this helps
> >
> > Since you have both the tables inside a single dataset & you want to
create 2 seperate xml file (each for a table)
> >
> > // this will write xml for table 1
> > DataTable dt2 = ds.Tables("Table2")
> > ds.Tables.Remove(dt2);
> >
> > ds.Writexml("c:\table1.xml");
> >
> > // after this is done, add table2 & remove table1
> > ds.Tables.Add(dt2);
> >
> > DataTable dt1 = ds.Tables("Table1")
> > ds.Tables.Remove(dt1);
> >
> > ds.Writexml("c:\table2.xml");
> >
> > // after both the things are done, add back table1
> > ds.Tables.Add(dt1);
> >
> > HTH :-)
> > Kalpesh
>
> Kalpesh,
>
> Thanks for your help. The problem I see with your solution is that
> there is an open form bound to that dataset at the moment of XML
> writing. That is, when I remove Table2 from dataset, the data bound to
> the form will disappear too. I guess I will just create two datasets.
>
> Grawsha