Wednesday, 30 May 2012

How to convert the table values to XML file and XSD file

SqlConnection Con = new SqlConnection("server=.;uid=.;Pwd=.;database=.");
SqlDataAdapter da = new SqlDataAdapter("Select top 10 * from SoftLawrence", Con);
DataSet DS = new DataSet();
da.Fill(DS);
DS.WriteXml("F:\\SoftLawrence\\Sample.XML");
DS.WriteXmlSchema("F:\\SoftLawrence\\Test.XSD");

//To convert the Xml file to Dataset
DataSet dsVat = new DataSet();
string appPath =  GetExecutingPath();
dsVat.ReadXml(appPath + "Sample.xml");
 return dsVat;

No comments:

Post a Comment