An example of structure and method of infinite level catalogue database

Source: Internet
Author: User
Folder table:
FolderID: Directory ID, automatic numbering
Folderparentid: Superior Catalogue Id,int
FolderName: directory name, Varchar
Folderdescription: Directory Description, Varchar
File table:
Fileid: Document ID, automatic numbering
Filefolderid: Owning directory Id,int
FileName: Document name, Varchar
FileDescription: Document contents, varchar or notes (ntext)
function Getallchildid (ID)
' Gets the FolderID of all subdirectories in the directory with FolderID ID, separated by a half-width comma
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
' Get SQL for all documents in a directory from table file
Dim Allchildid
Allchildid = Getallchildid (5) ' obtains FolderID for all directories under 5 FolderID
Allfilesql = "Select Fileid,filename from [File] where Filefolderid in (" & Allchildid & ")"
?
function FolderPath (ID)
' Get a full path to a directory
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 ' Output (Technical documents > Web Development > ASP > Code Sample > Form >)

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.