Skip to content

Instantly share code, notes, and snippets.

@jdowd7
Created August 14, 2015 14:08
Show Gist options
  • Save jdowd7/255d17fad70cdda3465e to your computer and use it in GitHub Desktop.
Save jdowd7/255d17fad70cdda3465e to your computer and use it in GitHub Desktop.
Converts any datatable to serializable XML
private string ConvertDatabaseToXML(DataTable dt)
{
System.IO.MemoryStream memory = new System.IO.MemoryStream();
dt.WriteXml(memory, true);
memory.Seek(0, System.IO.SeekOrigin.Begin);
System.IO.StreamReader memReader = new System.IO.StreamReader(memory);
string xmlResults;
xmlResults = memReader.ReadToEnd();
return xmlResults;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment