Monday, 23 April 2012

Generate XML from Dataset


   protected void generateXML_Click(object sender, EventArgs e)
        {
            // Define Connection with connection string
            SqlConnection con = new SqlConnection("Add ConnectionString");
            // write query to retrieve data.
            SqlCommand cmd = new SqlCommand("select * from DetailMaster", con);
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataSet ds = new DataSet();   // Take Dataset
            da.Fill(ds);
            ds.WriteXml("D:/textXML.xml");  // Path to create XML
        }

No comments:

Post a Comment