Tree Structure

Results 1 to 2 of 2

Thread: Tree Structure

  1. #1
    Join Date
    Dec 1969

    Default Tree Structure

    What are the different ways of implementing a tree structure in an ASP page?

  2. #2
    Join Date
    Dec 1969

    Default Not pratical, but use a recursive call...

    I did one with a recursive call to a database, HIGHLY inefficant, but it worked...<BR><BR>Table:Messages <BR>------------------------ <BR>Message_ID Message_Subject Message_Root <BR>------------------------------------------------------- <BR>1 A Root Message 0 <BR>2 A Sub from the root 1 <BR>3 A Sub of a Sub 2 <BR>4 Another Sub from the root 1 <BR>5 Another Root Message 0 <BR>6 This is a sub from that root message 5 <BR><BR>Message_id is the primary key and is an auto number <BR>message_root is a foreign key to a message within that same table... You use a recursive call to trace a thread down to its last message using the following code... <BR><BR><BR>&#060;% <BR>sub processpath(id, space) <BR>&#039;Set up the database connection <BR>strConnect="Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & server.mappath("test.mdb") <BR>set ObjConn=Server.CreateObject("ADODB.Connection") <BR>&#039;Set up the SQL command, looking for messages that point <BR> &#039;to messages <BR>&#039;of requested ID <BR>SQL = "Select * from messages where message_root = " & id <BR> strconnect <BR>set objrec = objconn.execute(SQL) <BR>&#039;Now loop through the recordset <BR>while not objrec.eof <BR>&#039;Now print what is in the database <BR> response.write(space & objrec("message_subject") & _ <BR> " <BR>") <BR>&#039;Set up the spaces to the next message <BR>outstr = space & _ <BR> " " <BR>&#039;Find any sub messages using a recursive cal <BR>processpath objrec("message_id"),outstr <BR>objrec.movenext <BR>wend <BR>objconn.close <BR>set objrec = nothing <BR>end sub <BR><BR><BR>processpath 0, "" <BR><BR>%&#062; <BR><BR>Have fun!<BR><BR>-- Whol

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts