首页 > 数据库 > mysql教程 > 数据库取值形成xml实现tree

数据库取值形成xml实现tree

WBOY
发布: 2016-06-07 15:15:51
原创
1461 人浏览过

Create three .aspx files TreeViewDataSet.aspx %@ import Namespace="Microsoft.Web.UI.WebControls" % %@ Register TagPrefix="IE" Namespace="Microsoft.Web.UI.WebControls" Assembly="Microsoft.Web.UI.WebControls" % html head title TreeViewDataSe

Create three .aspx files

TreeViewDataSet.aspx




<br>TreeViewDataSet.aspx<br>



 AutoPostBack="True"
 TreeNodeSrc="Categories.aspx"
 Runat="Server"/>


Categories.aspx

 mycon=New Sqlconnection("Server=localhost;UID=sa;PWD=secret;Database=Northwind")
 strQuery="select categoryname as Text,'products.aspx?catid='
 +LTRIM(STR(CategoryID))" & _
 "As TreeNodeSrc from Categories As TreeNode for xml auto, XMLDATA"
 cmdCategories=new SqlCommand(strQuery,mycon)
 dsCategories=New DataSet
 dsCategories.ReadXML(cmdCategories.ExecuteXmlReader(),XmlReadMode.Fragment)
 dsCategories.DataSetName="TREENODES"
 dsCategories.WriteXml(Response.OutputStream)
end sub

Products.aspx

 mycon=New Sqlconnection("Server=localhost;UID=sa;PWD=secret;Database=Northwind")
 strQuery="select Productname as Text from products As TreeNode" & _
 " where CategoryID=@categoryID for xml auto, XMLDATA "
 cmdproducts=new SqlCommand(strQuery,mycon)
 cmdproducts.Parameters.Add(New SqlParameter("@categoryID",Request.QueryString("catID")))
 mycon.open()
 dsproducts=New DataSet
 dsproducts.ReadXML(cmdproducts.ExecuteXmlReader(),XmlReadMode.Fragment)
 dsproducts.DataSetName="TREENODES"
 dsproducts.WriteXml(Response.OutputStream)
 mycon.close()
end sub

相关标签:
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板