利用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) & "
response.write(" |
" & chr(13))
response.write(" |
|
" & chr(13))
response.write("" & chr(13) & "
" & 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("" & chr(13) & "" & chr(13))
response.write("" & chr(13) & "
|