asp实现树型结构
网络编程 2021-07-05 10:58www.168986.cn编程入门
蛙蛙推荐:asp实现树型结构 选择自 onlytiancai 的 Blog
关键字 蛙蛙推荐:asp实现树型结构
出处
<!--
-----------[test]表生成脚本---------------
if exists (select from dbo.sysobjects where id = object_id(N'[dbo].[test]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[test]
GO
CREATE TABLE [dbo].[test] (
[id] [int] IDENTITY (1, 1) NOT NULL ,
[str_note] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
[father_id] [int] NULL
) ON [PRIMARY]
GO
-->
<!--
测试数据
[id][str_note][father_id]
[1][电脑书籍][0]
[2][软件开发][1]
[3][硬件维修][1]
[4][asp][2]
[5][php][2]
[6][jsp][2]
[7][html][2]
[8][显示器维修][3]
[9][主板维修][3]
[10][显卡维修][3]
[11][vbs基础][4]
[12][html基础][4]
[13][ado基础][4]
[14][do语句][11]
[15][for语句][11]
[16][select语句][11]
-->
<%
Dim strconn,conn,rs,sql
strconn="Driver={sql server};server=localhost;database=wawavote;uid=sa;pwd=sa;"
Dim i
i=0
Function ShowTree(parentID)
i=i+1
Dim rs
Set rs = Server.CreateObject("ADODB.RecordSet")
sql="SELECT id, str_note, father_id,(SELECT str_note FROM test t2 WHERE t2.id = t1.father_id) AS ParentName FROM test t1 WHERE t1.father_id="&Cint(parentID)
rs.open sql,strconn,1,1
Do While Not rs.Eof
for j=1 to i
Response.Write("---")
next
Response.Write(rs(1)&"["&rs(3)&"]<br>")
ShowTree rs(0)
i=i-1
rs.Movenext
Loop
rs.Close:Set rs=Nothing
End Function
Sub ShowTable(table)
Dim rs
Set rs = Server.CreateObject("ADODB.RecordSet")
sql="select from "&trim(table)
rs.open sql,strconn,1,1
For i=0 To rs.Fields.Count-1
Response.Write("["&rs.fields(i).Name&"]")
next
Response.Write("<br>")
Do While Not rs.Eof
For i=0 To rs.Fields.Count-1
Response.Write("["&rs.fields(i).Value&"]")
next
Response.Write("<br>")
rs.MoveNext
Loop
rs.Close:Set rs=Nothing
End sub
ShowTree(0)
ShowTable("test")
%>
关键字 蛙蛙推荐:asp实现树型结构
出处
<!--
-----------[test]表生成脚本---------------
if exists (select from dbo.sysobjects where id = object_id(N'[dbo].[test]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[test]
GO
CREATE TABLE [dbo].[test] (
[id] [int] IDENTITY (1, 1) NOT NULL ,
[str_note] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
[father_id] [int] NULL
) ON [PRIMARY]
GO
-->
<!--
测试数据
[id][str_note][father_id]
[1][电脑书籍][0]
[2][软件开发][1]
[3][硬件维修][1]
[4][asp][2]
[5][php][2]
[6][jsp][2]
[7][html][2]
[8][显示器维修][3]
[9][主板维修][3]
[10][显卡维修][3]
[11][vbs基础][4]
[12][html基础][4]
[13][ado基础][4]
[14][do语句][11]
[15][for语句][11]
[16][select语句][11]
-->
<%
Dim strconn,conn,rs,sql
strconn="Driver={sql server};server=localhost;database=wawavote;uid=sa;pwd=sa;"
Dim i
i=0
Function ShowTree(parentID)
i=i+1
Dim rs
Set rs = Server.CreateObject("ADODB.RecordSet")
sql="SELECT id, str_note, father_id,(SELECT str_note FROM test t2 WHERE t2.id = t1.father_id) AS ParentName FROM test t1 WHERE t1.father_id="&Cint(parentID)
rs.open sql,strconn,1,1
Do While Not rs.Eof
for j=1 to i
Response.Write("---")
next
Response.Write(rs(1)&"["&rs(3)&"]<br>")
ShowTree rs(0)
i=i-1
rs.Movenext
Loop
rs.Close:Set rs=Nothing
End Function
Sub ShowTable(table)
Dim rs
Set rs = Server.CreateObject("ADODB.RecordSet")
sql="select from "&trim(table)
rs.open sql,strconn,1,1
For i=0 To rs.Fields.Count-1
Response.Write("["&rs.fields(i).Name&"]")
next
Response.Write("<br>")
Do While Not rs.Eof
For i=0 To rs.Fields.Count-1
Response.Write("["&rs.fields(i).Value&"]")
next
Response.Write("<br>")
rs.MoveNext
Loop
rs.Close:Set rs=Nothing
End sub
ShowTree(0)
ShowTable("test")
%>
上一篇:超级ASP大分页_我的类容我做主
下一篇:如何把ASP编写成DLL
编程语言
- 如何快速学会编程 如何快速学会ug编程
- 免费学编程的app 推荐12个免费学编程的好网站
- 电脑怎么编程:电脑怎么编程网咯游戏菜单图标
- 如何写代码新手教学 如何写代码新手教学手机
- 基础编程入门教程视频 基础编程入门教程视频华
- 编程演示:编程演示浦丰投针过程
- 乐高编程加盟 乐高积木编程加盟
- 跟我学plc编程 plc编程自学入门视频教程
- ug编程成航林总 ug编程实战视频
- 孩子学编程的好处和坏处
- 初学者学编程该从哪里开始 新手学编程从哪里入
- 慢走丝编程 慢走丝编程难学吗
- 国内十强少儿编程机构 中国少儿编程机构十强有
- 成人计算机速成培训班 成人计算机速成培训班办
- 孩子学编程网上课程哪家好 儿童学编程比较好的
- 代码编程教学入门软件 代码编程教程