<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="DataSetToXml" %>
Untitled Page
File: Default.aspx.cs
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Xml;
using System.Web.Configuration;
public partial class DataSetToXml : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string connectionString = WebConfigurationManager.ConnectionStrings["Pubs"].ConnectionString;
string SQL = "SELECT * FROM authors WHERE city='Oakland'";
SqlConnection con = new SqlConnection(connectionString);
SqlCommand cmd = new SqlCommand(SQL, con);
SqlDataAdapter adapter = new SqlDataAdapter(cmd);
DataSet ds = new DataSet("AuthorsDataSet");
con.Open();
adapter.Fill(ds, "AuthorsTable");
con.Close();
XmlDataDocument dataDoc = new XmlDataDocument(ds);
XmlControl.Document = dataDoc;
XmlControl.TransformSource = "authors.xslt";
}
}
File: Web.config
File: authors.xslt
version="1.0">
The Author List
Created through XML and XSLT
Name: ,
Phone: