Skip to content

Auto increment parent_no

Sidhartha Patnaik

Sidhartha Patnaik

Asked Apr 21, 2017, 4:52 AM EDT3 answers
Share
LinkedInX
Hello sir, I am developing a project on multi level marketing in asp.net with c#.
I am in a problem to generate parent_no in database from asp.net. I have attached an image. 
 
My requirement is The first one who will register will be the parent and then who will register will be its child and like generation wise. Every parent will have only 2 Children. and so on the tree will increase. All this registration will be on asp.net web page. So I am facing problem to generate parent_no in asp page and for each two entries the parent_no will same then increment by 1 then same for two entries and then increment by 1 as the parent_no (image attached).
 
Thanking you
Sidhartha Patnaik 

3 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    I worked with multilevel commissions in the past and the way I did was as follow
    Always starts with members with position = 0, parentId=SponsorId 
    Explain assuming that you have a "John Doe" as you First on the parent level
    John Doe   Position = 0 ParentId={His SponsorId} 
    Maddona   Position = 1 ParentId={John Doe} (Become position level 1 to John Doe)
    Bruce         Position = 2 ParentId={Moddona}  (Become position level 3 to John Doe and 2 to maddona)
    Larry          Position = 3 ParentId={Bruce} (Become position level 4 to John Doe)
    Mark          Position = 4 ParentId={Larry} (Become position level 5 to John Doe)
     
    Good luck 
     
    0
  • Sidhartha Patnaik
    0
    Hello, 
    Jose Saiz sir.
    I have a problem to insert parent_no from asp.net.. can you share me some code to generate and insert this parent_no to database ??
     
    Thanks
    Sidhartha. 
    0
  • 0
    How about counting the members under that parent
     
    ---SQL Procedure 
    Declare @ParentCounter int, @TotalCounted int
    SET  @ParentCounter=0
    SET @TotalCounted = count(memberId) from members where parentId=@ParentId
     
    While  @ParentCounter<=@TotalCounted
    SET @ParentCounter + @ParentCounter + 1 
    store the value of the @ParentCounter in the Parent_no 
    Loop 
     
    Hope that works 
    0