GET Values from table in a recursive manner

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sentimental37
    New Member
    • May 2010
    • 23

    GET Values from table in a recursive manner

    I am trying to work with C# and i am stuck here. My problem is i want to retrieve the count of all the users in a specific side. Let me Explain. Here is my table snapshot with sample data.


    Now what i want exactly is that i get the count of users in a specific side as i give a user id as a parameter.The data is stored in MS Sql Database and i have to implement this on a website so efficiency of code is also a issue.

    Suppose i give 1001 as input
    The output should be : Left:1 , Right: 8

    if 1002 is input
    The output should be : Left:5, Right:0

    if 1003 is input
    The output should be : Left:3, Right:0

    if 1004 is input
    The output should be : Left:0, Right:0

    if 1005 is input
    The output should be : Left:1, Right:1

    and so on. So please provide me some logic on how to implement this thing.
    I also want to get a code which would return an array of all child users of a particular ID in a hierarchical manner so that i could process that data with RadOrgChart Control.
    Please help me.its very critical
    Attached Files
  • psurvi
    New Member
    • Nov 2013
    • 6

    #2
    You can write a select query to retrieve SponsorID and Pair side depending on the entered ID. Store this output in the dataset.
    Now loop through the dataset and then check the below condition
    Code:
    if(ds.Tables[0].Rows[0][index].ToString()=="LEFT")
    Left++;
    else
    right++;
    Hope this helps you.

    Comment

    Working...