Recursion Problem

Results 1 to 2 of 2

Thread: Recursion Problem

  1. #1
    Join Date
    Dec 1969

    Default Recursion Problem

    Hi,<BR>I&#039;m attempthing to do a preorder traversal of a tree like structure, but i&#039;m having problems with it. What seems to be happening is when the function pops back the recordset seems to be gone.<BR><BR>let me try to explain the whole set up here without wasting too much of your time...<BR><BR>database has 2 columns that matter, a category name and its parent. its a hierarchy of categories, and when deleting a top category i want to remove all the categories below it in one fell swoop :) so say the top category was Home, below it would be say 3 categories One, Two, Three. Each of those categories (one two and three) would have Home in its Parent field. As you can see it gets like a tree structure as you grow out categories.<BR><BR>psudo code it is somewhat like this:<BR><BR>tPreOrder(tree)<BR><BR>delete current tree from the db<BR>rsForest = get a list of categories whos parent = tree<BR>fPreOrder(rsForest)<BR><BR>end tPreOrder<BR><BR>--------------------------------<BR><BR>fPreOrder(rsForest)<BR><BR>if not rsForest.eof then<BR>*****tPreOrder(rsForest("Category"))<BR>** ***&#039;HERE IS THE PROBLEM! :)<BR>*****rsForest.movenext<BR>*****fPreOrder(rsF orest)<BR>end if<BR><BR>end fPreOrder<BR><BR>Ok so as you have probably noticed there is a &#039;HERES THE PROB comment where the error occurs.. its your typical<BR><BR>ADODB.Recordset error &#039;800a0bcd&#039; <BR><BR>Either BOF or EOF is True, or the current record has been deleted; the operation requested by the application requires a current record. <BR><BR>So here is whats happening, It gets the intial list of categories (One Two Three) and passes them to the forest function, when it gets there it passes the eof check and then calls the tree function again. This works all the way down until you hit a leif in the tree. When you get to the end and it is time for the function to pop back up the tree and do a movenext i get the error stated above, so somewhere it is losing track of the recordset.<BR><BR>I&#039;ve always had trouble with recursion so maybe there is something wrong with the logic, or perhaps asp doesnt work properly with recrusion? Also, i&#039;m wonding how bad it is to be passing a recordset around recursivly is. Should i use something like getrows and pass an array around instead? Is the fact that i&#039;m using a recordset causing the problem? <BR><BR>Anyway, thank you very much for reading through my post and even more thanks if you have any ideas for me :)<BR><BR>James

  2. #2
    Join Date
    Dec 1969

    Default Datashaping?>

    Have you tried using MSDataShape as the ODBC provider? Its perfect for parent &#062; child &#062; grandchild recordset relationships

Posting Permissions

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