asp实现树型结构
2018-09-06 10:45
蛙蛙推荐:asp实现树型结构选择自onlytiancai的Blog
关键字蛙蛙推荐:asp实现树型结构
出处
<!--
-----------[test]表生成脚本---------------
ifexists(select*fromdbo.sysobjectswhereid=object_id(N[dbo].[test])andOBJECTPROPERTY(id,NIsUserTable)=1)
droptable[dbo].[test]
GO
CREATETABLE[dbo].[test](
[id][int]IDENTITY(1,1)NOTNULL,
[str_note][nvarchar](50)COLLATEChinese_PRC_CI_ASNULL,
[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]
***************************************************
-->
<%
Dimstrconn,conn,rs,sql
strconn=Driver={sqlserver};server=localhost;database=wawavote;uid=sa;pwd=sa;
Dimi
i=0
FunctionShowTree(parentID)
i=i+1
Dimrs
Setrs=Server.CreateObject(ADODB.RecordSet)
sql=SELECTid,str_note,father_id,(SELECTstr_noteFROMtestt2WHEREt2.id=t1.father_id)ASParentNameFROMtestt1WHEREt1.father_id=&Cint(parentID)
rs.opensql,strconn,1,1
DoWhileNotrs.Eof
forj=1toi
Response.Write(---)
next
Response.Write(rs(1)&[&rs(3)&]<br>)
ShowTreers(0)
i=i-1
rs.Movenext
Loop
rs.Close:Setrs=Nothing
EndFunction
SubShowTable(table)
Dimrs
Setrs=Server.CreateObject(ADODB.RecordSet)
sql=select*from&trim(table)
rs.opensql,strconn,1,1
next
Response.Write(<br>)
DoWhileNotrs.Eof
Fori=0Tors.Fields.Count-1
Response.Write([&rs.fields(i).Value&])
next
Response.Write(<br>)
rs.MoveNext
Loop
rs.Close:Setrs=Nothing
Endsub
ShowTree(0)
ShowTable(test)
%>
下一篇:TSYS 新闻列表JS调用下载