tags:

views:

31

answers:

1

I am using a dataset and storing a Query result into that data set. My Query id is like that

String Query = @"SELECT * FROM TABLE1;
                 SELECT * FROM TABLE2;
                 SELECT * FROM TABLE3;";

I am using following thing

XmlDocument relationSheepDoc = new XmlDocument();
    StringWriter sWriter = new StringWriter();
    XmlTextWriter xmlWriter = new XmlTextWriter(sWriter);
    DataSet oDataSet = new DataSet("RelationSheeps");
     oDataSet = sql.ExecuteSqlDataSet(Query);
    string fileContent = string.Empty;
       for (int i = 0; i < oDataSet.Tables.Count; i++)
        {
            oDataSet.Tables[i].WriteXml(xmlWriter, XmlWriteMode.WriteSchema);
            fileContent = sWriter.ToString();               

        }
        relationSheepDoc.LoadXml(fileContent);
        xmlWriter.Close();

        return relationSheepDoc;

It write only first table and generates Exception How can i write All three table in the same XML file? Help me...

A: 

You should write the entire DataSet at once, like this:

oDataSet.WriteXml(xmlWriter, XmlWriteMode.WriteSchema);
SLaks
it doesnot work
subodh
Why not? What error do you get?
SLaks