Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 87343
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T22:23:17+00:00 2026-05-10T22:23:17+00:00

When I call this function, everything works, as long as I don’t try to

  • 0

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:

GetChilds rsData('AcctID'), intLevel + 1  

Then the function breaks.

<%     Function GetChilds(ParentID, intLevel)         Set rsData= Server.CreateObject('ADODB.Recordset')         sSQL = 'SELECT AcctID, ParentID FROM Accounts WHERE ParentID='' & ParentID &'''         rsData.Open sSQL, conDB, adOpenKeyset, adLockOptimistic         If IsRSEmpty(rsData) Then             Response.Write('Empty')         Else             Do Until rsData.EOF                 Response.Write rsData('AcctID') & '<br />'                 'GetChilds rsData('AcctID'), intLevel + 1                  rsData.MoveNext             Loop         End If         rsData.close: set rsData = nothing     End Function      Call GetChilds(1,0) %> 

*Edited after feedback

Thanks everyone,

Other than the usual error:

Error Type: (0x80020009) Exception occurred. 

I wasn’t sure what was causing the problems. I understand that is probably due to a couple of factors.

  1. Not closing the connection and attempting to re-open the same connection.
  2. To many concurrent connections to the database.

The database content is as follows:

AcctID | ParentID 1        Null 2        1 3        1 4        2 5        2 6        3 7        4 

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?

Thanks for the quick responses.


Thanks everyone,

Other than the usual error:

Error Type: (0x80020009) Exception occurred.

I wasn’t sure what was causing the problems. I understand that is probably due to a couple of factors.

  1. Not closing the connection and attempting to re-open the same connection.
  2. To many concurrent connections to the database.

The database content is as follows:

AcctID | ParentID 1        Null 2        1 3        1 4        2 5        2 6        3 7        4 

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?

Thanks for the quick responses.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T22:23:17+00:00Added an answer on May 10, 2026 at 10:23 pm

    Look like it fails because your connection is still busy serving the RecordSet from the previous call.

    One option is to use a fresh connection for each call. The danger there is that you’ll quickly run out of connections if you recurse too many times.

    Another option is to read the contents of each RecordSet into a disconnected collection: (Dictionary, Array, etc) so you can close the connection right away. Then iterate over the disconnected collection.

    If you’re using SQL Server 2005 or later there’s an even better option. You can use a CTE (common table expression) to write a recursive sql query. Then you can move everything to the database and you only need to execute one query.

    Some other notes:
    ID fields are normally ints, so you shouldn’t encase them in ‘ characters in the sql string.

    Finally, this code is probably okay because I doubt the user is allowed to input an id number directly. However, the dynamic sql technique used is very dangerous and should generally be avoided. Use query parameters instead to prevent sql injection.

    I’m not too worried about not using intLevel for anything. Looking at the code this is obviously an early version, and intLevel can be used later to determine something like indentation or the class name used when styling an element.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 90k
  • Answers 90k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Maybe you problem is that the Flash app is not… May 11, 2026 at 6:05 pm
  • Editorial Team
    Editorial Team added an answer The user acceptance test cases should be detailed and simple… May 11, 2026 at 6:05 pm
  • Editorial Team
    Editorial Team added an answer I use it for an intranet application and have done… May 11, 2026 at 6:05 pm

Related Questions

When I call this function, everything works, as long as I don't try to
I have an third part dll that have a function that returns a string.
I have a Visual Studio 2008 solution with two projects (a Word-Template project and
I need to return an array of initialized objects from VB6 into C# using
Has anyone seen this error when trying to call an external C function from

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.