Home > Database > Mysql Tutorial > 使用DW用ASP+ACCESS编写目录树

使用DW用ASP+ACCESS编写目录树

WBOY
Release: 2016-06-07 15:15:59
Original
2385 people have browsed it

利用ACCESS创建数据库listBase.mdb: 数据表:listTable 数据字段:listIdlistNamelistInfoparentId 连接方法: % dimsConn,sConnStr,sSql sConnStr="DRIVER={MicrosoftAccessDriver(*.mdb)};dbq="server.mappath("listBase.mdb") setsConn=server.createobjec

利用ACCESS创建数据库listBase.mdb:

数据表:listTable

数据字段:listIdlistNamelistInfoparentId 连接方法:


dimsConn,sConnStr,sSql

sConnStr="DRIVER={MicrosoftAccessDriver(*.mdb)};dbq="&server.mappath("listBase.mdb")

setsConn=server.createobject("adodb.connection")

sConn.opensConnStr

%>

把以上代码保存成文件:initialize.asp 下面这段程序代码是用来显示目录树用的,保存成文件:inc.asp








response.write("" & chr(13))

response.write("" & chr(13)&"" & chr(13))

response.write("" & chr(13) & "" & chr(13) & "" & chr(13) & "
" & chr(13) & "")

response.write("" & chr(13) & "" & chr(13))

response.write("
使用DW用ASP+ACCESS编写目录树
response.write("
 
" & chr(13))

'下面代码为显示目录树最关键的函数,使用了递归方法(很多象这样类型的都是用递归来做的。)

function listChild(id)

dim sRec,sSql,sNum,sTmp

set sRec=server.createobject("adodb.recordset")

sSql="select listId,listName,listInfo,parentId from listTable where parentId=" & id

sRec.open sSql,sConn,3,1

if not sRec.eof then

sNum=1

response.write("" & chr(13))

while not sRec.eof

sTmp=sConn.execute("select count(listId) as countSub from listTable where parentId=" & sRec("listId"))

if sTmp("countSub")>0 then

response.write("" & chr(13))

if sNum=sRec.recordcount then

response.write("" & chr(13))

else

response.write("" & chr(13))

end if

response.write("
使用DW用ASP+ACCESS编写目录树使用DW用ASP+ACCESS编写目录树" & chr(13) & "" & chr(13))

response.write("" & chr(13) & "
if sNum=sRec.recordcount then

response.write("
response.write("使用DW用ASP+ACCESS编写目录树")

response.write("" & chr(13))

else

response.write("" & chr(13))

end if

response.write("" & chr(13) & "" & chr(13))

else

response.write("" & chr(13))

if sNum=sRec.recordcount then

response.write("" & chr(13))

else

response.write("" & chr(13))

end if

response.write("
使用DW用ASP+ACCESS编写目录树使用DW用ASP+ACCESS编写目录树" & chr(13) & "" & chr(13))

response.write("" & chr(13) & "" & chr(13) & "
" & chr(13))

end if

sRec.close '关闭记录集

set sRec=nothing '关闭记录集

end function

sConn.close '关闭数据库链接

set sConn=nothing '关闭数据库链接

%>

下面这是调用页代码,保存成index.asp









<strong></strong>
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template