using System;
using System.Data;
using System.Data.SqlClient;
using System.Xml;
using System.Xml.Xsl;
public class XslTransformDataSet
{
private static string connectionString = "Data Source=localhost;Initial Catalog=Northwind;Integrated Security=SSPI";
public static void Main()
{
string SQL = "SELECT TOP 5 * FROM Customers";
SqlConnection con = new SqlConnection(connectionString);
SqlCommand com = new SqlCommand(SQL, con);
SqlDataAdapter adapter = new SqlDataAdapter(com);
DataSet ds = new DataSet("CustomerDataSet");
con.Open();
adapter.FillSchema(ds, SchemaType.Mapped, "Customers");
adapter.Fill(ds, "Customers");
con.Close();
XmlDataDocument dataDoc = new XmlDataDocument(ds);
XslTransform xsl = new XslTransform();
xsl.Load("transform.xsl");
xsl.Transform(dataDoc, null, Console.Out);
}
}
|