Posts

Showing posts with the label DataTable

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)) { con.Open(); string Query = "select col1,col2 from table " ; SqlDataAdapter da = new SqlDataAdapter(Query, con); da.Fill(ds,"TableName"); ds.Tables[ "TableName" ].WriteXml( "XML File Path" ); } Hope this help you :-) Any Suggestion s on this article are welcome :-)