Read the data into a DataTable, and use the
DataTable.WriteXml[
^] method.
DataTable dt = new DataTable("Videos");
using (SqlConnection con = new SqlConnection(GenericData.DBConnection))
{
con.Open();
using (SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM Videos", con))
{
da.Fill(dt);
using (StreamWriter sw = new StreamWriter(@"D:\Temp\videos.xml"))
{
dt.WriteXml(sw);
sw.Flush();
}
}
}
[edit]Eh? Where did the code go? - OriginalGriff[/edit]