Mega Code Archive

 
Categories / C# Tutorial / ADO Net
 

Transform Data

using System; using System.Data; using System.Data.SqlClient; using System.Xml; using System.Xml.Xsl; public class MainClass{   public static void Main(string [] args) {     DataSet dataSet = new DataSet("Product");          SqlConnection connection = new SqlConnection("Initial Catalog=Product; Integrated Security=SSPI; User ID=sa");          SqlDataAdapter customersAdapter = new SqlDataAdapter("SELECT * FROM customers", connection);     SqlDataAdapter couponsAdapter = new SqlDataAdapter("SELECT * FROM coupons", connection);     SqlDataAdapter couponRedemptionsAdapter = new SqlDataAdapter("SELECT * FROM coupon_redemptions", connection);          customersAdapter.Fill(dataSet, "customers");     couponsAdapter.Fill(dataSet, "coupons");     couponRedemptionsAdapter.Fill(dataSet, "coupon_redemptions");     XmlDataDocument doc = new XmlDataDocument(dataSet);          XmlTextWriter writer = new XmlTextWriter(Console.Out);     writer.Formatting = Formatting.Indented;          XslTransform transform = new XslTransform();     transform.Load("Coupons.xsl");     transform.Transform(doc, null, writer);   } }