My FAQ,最新最全的IT技术教程
最新100篇 | 推荐100篇 | 专题100篇 | 排行榜 | 搜索 | 在线API文档
首 页 | 程序开发 | 操作系统 | 软件应用 | 图形图象 | 网络应用 | 精文荟萃 | 教育认证 | 硬件维护 | 未整理篇 | 站长教程
ASP JS PHP工程 ASP.NET 网站建设 UML J2EESUN .NET VC VB VFP 网络维护 数据库 DB2 SQL2000 Oracle Mysql
服务器 Win2000 Office C DreamWeaver FireWorks Flash PhotoShop 上网宝典 CorelDraw 协议大全 网络安全 微软认证
硬件维护  CPU  主板  硬盘  内存  显卡  显示器  键盘鼠标  声卡音箱  打印机  机箱电源  BIOS  网卡  C#  Java  Delphi  vs.net2005
  当前位置:> 程序开发 > Web开发 > Asp > 综合文章
无限级目录数据库结构与方法一例
作者:未知 时间:2005-01-13 12:12 出处:Blog 责编:MyFAQ
              摘要:暂无

Folder 表:
Folderid:目录ID,自动编号
FolderParentID:上级目录ID,Int
FolderName:目录名称,Varchar
FolderDescription:目录说明,Varchar

File 表:
FileID:文档ID,自动编号
FileFolderID:所属目录ID,Int
FileName:文档名称,Varchar
FileDescription:文档内容,Varchar或备注(ntext)

function GetAllChildID(id)
    '取得FolderID为id的目录下所有子目录的FolderID,以半角逗号分开
    dim arrID
    arrID = id
    Set rsdir = Conn.Execute("Select FolderID,FolderParentID from [Folder] where FolderParentID = " & id & "")
    if rsdir.eof and rsdir.bof then
        set rsdir = nothing
        GetAllChildID = arrID
        exit function
    else
        while not rsdir.eof
            arrID = arrID & "," & GetAllChildID(rsdir("FolderID"))
        rsdir.movenext
        wend
    end if
    set rsdir = nothing
    GetAllChildID = arrID
end function


'从表File中取得某个目录下所有文档的Sql
dim AllChildID
AllChildID = GetAllChildID(5)    '取得FolderID为5下所有目录的FolderID
AllfileSql = "Select FileID,FileName from [File] where FileFolderID in ("& AllChildID &")"
?

function FolderPath(id)
    '得到一个目录的完整路径
    dim Pathstr,NewPathstr
    Set rsdir = Conn.Execute("Select FolderID,FolderName,FolderParentID from [Folder] where FolderID = " & id)
    if rsdir.bof and rsdir.eof then
        Pathstr = ""
    else
        Pathstr = "<a href=""Folder.asp?FolderID=" & rsdir("FolderID") &""">" & rsdir("FolderName") & "</a> > " & Pathstr
        if rsdir("FolderParentID") <> 0 then
            Pathstr = FolderPath(rsdir("FolderParentID")) & Pathstr
        end if
    end if

    NewPathstr = Pathstr
    set rsdir = nothing
    FolderPath = NewPathstr
end function

dim folderpathstr
folderpathstr = FolderPath(67)
response.write folderpathstr '输出 (技术文档 > Web开发 > ASP > Code Sample > 表单 > )

关闭本页
 
首页 | 投资与合作 | 服务条款 | 隐私政策 | 收藏本站 | 设为首页 | 新用户注册 | 免责声明 | 使用帮助
Copyright ©2005-2008 myfaq.com.cn All rights reserved. www.myfaq.com.cn 版权所有