Convert DataSet or DataTable to XML

Normally we face this problem where we have lots of data to convert into XML file from DataSet or DatTable  .Because XML file is readable by all languages.

Here I have some sample Snippet for Writing the DataSet or DataTable to XML format.

   DataSet ds = new DataSet();
   using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["CON"].ConnectionString))
                string Query = "select col1,col2 from table ";
                SqlDataAdapter da = new SqlDataAdapter(Query, con);
                ds.Tables["TableName"].WriteXml("XML File Path");

Hope this help you :-)

Any Suggestion s on this article are welcome :-)


Popular posts from this blog

How to hide bootStrap popover when user click(s) outside the popover?

Exporting to excel from a custom class object using C#.NET

Get the Clicked Cell Value and Column Name of GridView in ASP.NET