Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat's wrong with this ASP recursive function?
    text
    copied!<p>When I call this function, everything works, as long as I don't try to recursively call the function again. In other words if I uncomment the line:</p> <pre><code>GetChilds rsData("AcctID"), intLevel + 1 </code></pre> <p>Then the function breaks. </p> <pre><code>&lt;% Function GetChilds(ParentID, intLevel) Set rsData= Server.CreateObject("ADODB.Recordset") sSQL = "SELECT AcctID, ParentID FROM Accounts WHERE ParentID='" &amp; ParentID &amp;"'" rsData.Open sSQL, conDB, adOpenKeyset, adLockOptimistic If IsRSEmpty(rsData) Then Response.Write("Empty") Else Do Until rsData.EOF Response.Write rsData("AcctID") &amp; "&lt;br /&gt;" 'GetChilds rsData("AcctID"), intLevel + 1 rsData.MoveNext Loop End If rsData.close: set rsData = nothing End Function Call GetChilds(1,0) %&gt; </code></pre> <p>*Edited after feedback</p> <p>Thanks everyone,</p> <p>Other than the usual error:</p> <pre><code>Error Type: (0x80020009) Exception occurred. </code></pre> <p>I wasn't sure what was causing the problems. I understand that is probably due to a couple of factors.</p> <ol> <li>Not closing the connection and attempting to re-open the same connection.</li> <li>To many concurrent connections to the database.</li> </ol> <p>The database content is as follows:</p> <pre><code>AcctID | ParentID 1 Null 2 1 3 1 4 2 5 2 6 3 7 4 </code></pre> <p>The idea is so that I can have a Master Account with Child Accounts, and those Child Accounts can have Child Accounts of their Own. Eventually there will be Another Master Account with a ParentID of Null that will have childs of its own. With that in mind, am I going about this the correct way?</p> <p>Thanks for the quick responses.</p> <hr> <p>Thanks everyone,</p> <p>Other than the usual error:</p> <blockquote> <p>Error Type: (0x80020009) Exception occurred.</p> </blockquote> <p>I wasn't sure what was causing the problems. I understand that is probably due to a couple of factors.</p> <ol> <li>Not closing the connection and attempting to re-open the same connection.</li> <li>To many concurrent connections to the database.</li> </ol> <p>The database content is as follows:</p> <pre><code>AcctID | ParentID 1 Null 2 1 3 1 4 2 5 2 6 3 7 4 </code></pre> <p>The idea is so that I can have a Master Account with Child Accounts, and those Child Accounts can have Child Accounts of their Own. Eventually there will be Another Master Account with a ParentID of Null that will have childs of its own. With that in mind, am I going about this the correct way?</p> <p>Thanks for the quick responses.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload