Convert DataSet and DataTable to Xml String helper functions

I created 2 helper functions(can be modified as extensions in .Net Framework 3.5) to output/trace content of DataSet  or DataTable
public static string ToStringAsXml(DataSet ds)

{

 StringWriter sw = new StringWriter();
ds.WriteXml(sw, XmlWriteMode.IgnoreSchema);

string s = sw.ToString();

return s;

}
 

public static string ToStringAsXml(DataTable dt)
{
 StringWriter sw = new StringWriter();
dt.WriteXml(sw, XmlWriteMode.IgnoreSchema);
string s = sw.ToString();
return s;

}

posted @ Thursday, August 14, 2008 12:02 AM

Print

Comments on this entry:

# re: Convert DataSet and DataTable to Xml String helper functions

Left by Sandip at 12/27/2008 6:29 PM
Gravatar
Hi,
I did the same thing (converitng DataTable to Database). It is not working for the DataTable that i get from Database but works for DataTable constructed by me. Any clue to this problem???

# re: Convert DataSet and DataTable to Xml String helper functions

Left by Sandip at 12/27/2008 6:35 PM
Gravatar
Hi,
I resolved the Problem. I converted DataTable to Database and it started working fine.

# re: Convert DataSet and DataTable to Xml String helper functions

Left by yogesh at 8/18/2009 8:19 AM
Gravatar
can any body say me how to convert XML string to data set

# re: Convert DataSet and DataTable to Xml String helper functions

Left by Michael Freidgeim at 8/19/2009 7:22 AM
Gravatar
Use ReadXml method of the DataSet object.
http://msdn.microsoft.com/en-us/library/fx29c3yd.aspx.

# re: Convert DataSet and DataTable to Xml String helper functions

Left by Alessandro Gonzalez at 10/26/2009 2:22 PM
Gravatar
Muito interessante o post.

Your comment:



 (will not be displayed)


 
 
 
 
 

Live Comment Preview:

 
«November»
SunMonTueWedThuFriSat
25262728293031
1234567
891011121314
15161718192021
22232425262728
293012345