Home All Groups Group Topic Archive Search About

Probem with DataSet.GetXml()

Author
26 Oct 2006 8:32 AM
lucky
Hi guys!
i'm facing very strange problem.

i've a DataSet object in which i add some tables the some logic
finishes successfully. and after then i tried to get the XML string
from the DataSet but it returns only first 2 tables in that string.

here is the code that i'm using to add tables into the DataSet and then
tried to get the xml from the dataset

please note that i'm manually adding tables into the DataSet.
                    foreach (SQLTransaction t in Trans)
                    {
                        System.Data.DataSet ds;
                        ds = t.Execute();
                        if (ds != null)
                        {
                            foreach (System.Data.DataTable table in
ds.Tables)
                            {
                                dsResult.Tables.Add(table.Copy());
                            }
                        }
                    }

Gettting the xml from the dataset

                    dsResult.AcceptChanges();
                    string xml=dsResult.GetXml();

when i get the string from the dataset it returns xml of the first 2
tables regardless, it has more then 3 tables.

if anyone know where i'm making mistake, plesae let me know.

all suggestions,modification,alternate ways are welcome.

thanks,
Lucky

Author
26 Oct 2006 11:41 AM
Lucky
okey i've got the answer.

the DatSet wont produce xml for those tables, those doesnt have any
rows. If you still need xml, u have to use DataTable.WriteXml() method.

Have a nice day,
Lucky

lucky wrote:
Show quote
> Hi guys!
> i'm facing very strange problem.
>
> i've a DataSet object in which i add some tables the some logic
> finishes successfully. and after then i tried to get the XML string
> from the DataSet but it returns only first 2 tables in that string.
>
> here is the code that i'm using to add tables into the DataSet and then
> tried to get the xml from the dataset
>
> please note that i'm manually adding tables into the DataSet.
>                     foreach (SQLTransaction t in Trans)
>                     {
>                         System.Data.DataSet ds;
>                         ds = t.Execute();
>                         if (ds != null)
>                         {
>                             foreach (System.Data.DataTable table in
> ds.Tables)
>                             {
>                                 dsResult.Tables.Add(table.Copy());
>                             }
>                         }
>                     }
>
> Gettting the xml from the dataset
>
>                     dsResult.AcceptChanges();
>                     string xml=dsResult.GetXml();
>
> when i get the string from the dataset it returns xml of the first 2
> tables regardless, it has more then 3 tables.
>
> if anyone know where i'm making mistake, plesae let me know.
>
> all suggestions,modification,alternate ways are welcome.
>
> thanks,
> Lucky

AddThis Social Bookmark Button