Implementation of tree structure--application techniques by ASP
Source: Internet
Author: User
Frog Frog Recommended: ASP implementation of tree structure selection from Onlytiancai Blog
Frog Frog Recommended: ASP implementation of tree structure
Source
<!--
-----------the [test] table to generate a script---------------
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] (m) COLLATE chinese_prc_ci_as NULL,
[FATHER_ID] [INT] Null
) on [PRIMARY]
Go
-->
<!--
Test Data ********************
[ID] [Str_note] [FATHER_ID]
[1] [Computer Books] [0]
[2] [Software development] [1]
[3] [Hardware repair] [1]
[4] [ASP] [2]
[5] [PHP] [2]
[6] [JSP] [2]
[7] [HTML] [2]
[8] [Monitor Maintenance] [3]
[9] [Motherboard repair] [3]
[10] [Video card repair] [3]
[11] [VBS BASICS] [4]
[12] [HTML Basics] [4]
[13] [ADO Basics] [4]
[14] [Do statement] [11]
[15] [For statement] [11]
[16] [SELECT statement] [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 but 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 but 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")
%>
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service