大雀软件园

首页 软件下载 安卓市场 苹果市场 电脑游戏 安卓游戏 文章资讯 驱动下载
技术开发 网页设计 图形图象 数据库 网络媒体 网络安全 站长CLUB 操作系统 媒体动画 安卓相关
当前位置: 首页 -> 技术开发 -> ASP专区 -> asp实现树型结构

asp实现树型结构

时间: 2021-07-31 作者:daque

 <!-- -----------[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,sqlstrconn="driver={sql server};server=localhost;database=wawavote;uid=sa;pwd=sa;"dim ii=0function 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 functionsub 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 subshowtree(0)showtable("test")%>

热门阅览

最新排行

Copyright © 2019-2021 大雀软件园(www.daque.cn) All Rights Reserved.