SQLXML系列之一:SQLXML初体验——用XML代替SQL来操作数据库
2008-12-06 10:16:03 来源:WEB开发网7. 创建Web Page
现在我们来完成最后一步,创建两个Web Page。由于所有的Html都是通过SQLXML来实现的,所以连个Page不需要任何的HTML。只需要在Page Load 事件中编写下面的代码,就OK了。
Order.aspx.cs
protected void Page_Load(object sender, EventArgs e)
{
if (this.IsPostBack)
{
return;
}
//Utility.ExecuteIntoStream(this.Response.OutputStream, SqlXmlCommandType.TemplateFile, Utility.SqlTemplaeFile, 0, Utility.OrderXsltFile);
Utility.ExecuteIntoStream(this.Response.OutputStream, SqlXmlCommandType.TemplateFile, Utility.XpathTemplaeFile,"0", Utility.OrderXsltFile);
}
Utility.ExecuteIntoStream(this.Response.OutputStream, SqlXmlCommandType.TemplateFile, Utility.SqlTemplaeFile, 0, Utility.OrderXsltFile)和Utility.ExecuteIntoStream(this.Response.OutputStream, SqlXmlCommandType.TemplateFile, Utility.XpathTemplaeFile,"0", Utility.OrderXsltFile)具有一样的功能,大家可以使用试试,使用任何一个,得到的结果都是一样的。对于下面也一样.
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 Microsoft.Data.SqlXml;
public partial class OrderDetail : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (this.IsPostBack)
{
return;
}
int orderID = 1;
if (this.Request.QueryString["id"] != null)
{
if (!int.TryParse(this.Request.QueryString["id"], out orderID))
{
orderID = 1;
}
}
Utility.ExecuteIntoStream(this.Response.OutputStream, SqlXmlCommandType.TemplateFile, Utility.SqlTemplaeFile, orderID, Utility.OrderDetailXsltFile);
//Utility.ExecuteIntoStream(this.Response.OutputStream, SqlXmlCommandType.TemplateFile, Utility.XpathTemplaeFile, orderID.ToString(), Utility.OrderDetailXsltFile);
}
}
更多精彩
赞助商链接