Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 Retaining original table names during db to xml

Author  Topic 

sql_er
Constraint Violating Yak Guru

267 Posts

Posted - 2006-12-19 : 12:54:39
I am not sure whether this is a proper place to ask this question, but hoping someone might know:

I read a database into a DATASET in C#. I then output it as an XML file. In the XML file, the tables (which initially resided in my db) are called Table, Table1, Table2 ... respectively.

As such, when I query the XML file (i.e. the tables), I have to use these labels. Would anyone know how I can retain the orignal table names when the XML file is created?


Thank you very much

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-12-19 : 13:14:54
Which method are you using to save the content as a XML file?


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

sql_er
Constraint Violating Yak Guru

267 Posts

Posted - 2006-12-19 : 14:15:58
Dataset ds = SqlHelper.ExecuteDataset(connectionstring, CommandType.Text, sqlstring); //to load my data into ds

WriteXMLToFile(ds); // to write data into xml file

Below is the definition of WriteXMLToFile method
------------------------------------------------
private static void WriteXmlToFile(DataSet thisDataSet)
{
if (thisDataSet == null) { return; }

// Create a file name to write to.
string filename = "XmlDoc.xml";

// Create the FileStream to write with.
System.IO.FileStream stream = new System.IO.FileStream(filename, System.IO.FileMode.Create);

XmlWriteMode WriteSchema = new XmlWriteMode();

// Write to the file with the WriteXml method.
thisDataSet.WriteXml(stream, WriteSchema);

}

Thanks for the help
Go to Top of Page
   

- Advertisement -