| er("SELECT * FROM Customers", nwindConn)
custDA.Fill(myDataSet, "Customers")
Dim ordersDA As SqlDataAdapter = New SqlDataAdapter("SELECT * FROM Orders", nwindConn)
ordersDA.Fill(myDataSet, "Orders")
nwindConn.Close()
myDataSet.Relations.Add("CustOrders",_ myDataSet.Tables("Customers").Columns("CustomerID"),_ myDataSet.Tables("Orders").Columns("CustomerID")).Nested = true
Dim xmlDoc As XmlDataDocument = New XmlDataDocument(myDataSet)
Dim xslTran As XslTransform = New XslTransform
xslTran.Load("transform.xsl")
Dim writer As XmlTextWriter = New XmlTextWriter("xslt_output.html", System.Text.Encoding.UTF8)
xslTran.Transform(xmlDoc, Nothing, writer)
writer.Close()
End Sub
End Class
‘C#
using System;
using System.Data;
using System.Data.SqlClient;
using System.Xml;
using System.Xml.Xsl;
public class Sample
{
public static void Main()
{
SqlConnection nwindConn = new SqlConnection("Data Source=localhost;Initial Catalog=northwind;Integrated Security=SSPI;");
nwindConn.Open();
DataSet custDS = new DataSet("CustomerDataSet");
SqlDataAdapter custDA = new SqlDataAdapter("SELECT * FROM Customers", nwindConn);
custDA.Fill(custDS, "Customers");
SqlDataAdapter ordersDA = new SqlDataAdapter("SELECT * FROM Orders", nwindConn);
ordersDA.Fill(custDS, "Orders");
nwindConn.Close();
custDS.Relations.Add("CustOrders",
custDS.Tables["Customers"].Columns["CustomerID"],
custDS.Tables["Orders"].Columns["CustomerID"]).Nested = true;
XmlDataDocument xmlDoc = new XmlDataDocument(custDS);
XslTransform xslTran = new XslTransform();
xslTran.Load("transform.xsl");
XmlTextWriter writer = new XmlTextWriter("xslt_output.html", System.Text.Encoding.UTF8);
xslTran.Transform(xmlDoc, null, writer);
writer.Close();
}
}
ADO.NET最佳实践(中)
http://www.csdn.net/Develop/read_article.asp?id=22663
上一页 [1] [2] [3] [4] [5] |