asp實(shí)現(xiàn)樹型結(jié)構(gòu)
更新時(shí)間:2007年03月12日 00:00:00 作者:
蛙蛙推薦:asp實(shí)現(xiàn)樹型結(jié)構(gòu) 選擇自 onlytiancai 的 Blog
關(guān)鍵字 蛙蛙推薦:asp實(shí)現(xiàn)樹型結(jié)構(gòu)
出處
<!--
-----------[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
-->
<!--
***********************測試數(shù)據(jù)********************
[id][str_note][father_id]
[1][電腦書籍][0]
[2][軟件開發(fā)][1]
[3][硬件維修][1]
[4][asp][2]
[5][php][2]
[6][jsp][2]
[7][html][2]
[8][顯示器維修][3]
[9][主板維修][3]
[10][顯卡維修][3]
[11][vbs基礎(chǔ)][4]
[12][html基礎(chǔ)][4]
[13][ado基礎(chǔ)][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")
%>
關(guān)鍵字 蛙蛙推薦:asp實(shí)現(xiàn)樹型結(jié)構(gòu)
出處
<!--
-----------[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
-->
<!--
***********************測試數(shù)據(jù)********************
[id][str_note][father_id]
[1][電腦書籍][0]
[2][軟件開發(fā)][1]
[3][硬件維修][1]
[4][asp][2]
[5][php][2]
[6][jsp][2]
[7][html][2]
[8][顯示器維修][3]
[9][主板維修][3]
[10][顯卡維修][3]
[11][vbs基礎(chǔ)][4]
[12][html基礎(chǔ)][4]
[13][ado基礎(chǔ)][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")
%>
相關(guān)文章
關(guān)于靜態(tài)頁生成問題 突破form數(shù)量限制
關(guān)于靜態(tài)頁生成問題 突破form數(shù)量限制...2006-09-09ASP 連接Access數(shù)據(jù)庫的登陸系統(tǒng)
這篇文章主要為大家詳細(xì)介紹了ASP 連接Access數(shù)據(jù)庫的登陸系統(tǒng),感興趣的小伙伴們可以參考一下2016-07-07談動(dòng)態(tài)多行多列,循環(huán)行和列,輸出M行N列的ASP代碼
2008-03-03