I have a Client Database that tracks who people have referred to us as new clients. I would like to get this into a dataset and bind a treeview control to it. I am trying to write a Stored procedure that pulls that information so I can populate a VB.net datatable. But, the kicker is that I also want the people that referer referred and on down the line. For example...
- Larry Smith
- Bob Smith
- Jane Doe
- Jack Doe
- Jill Doe
- Larry Brown
and on and on. It will need to iterate as many times as necessary to get all of the info and place into a table.
I have no clue how to do this.
I can easily get the data one time, "Select ClientName from [Client Table] Where Referred By = @Var" But beyond that it escapes me.
The data structure needed will be something like:
ClientName Parent_ClientID ReferredBy_ClientID
Joe Smith 1001 0
Bob Smith 2001 1001
Jane Doe 3001 2001
Jack Doe 4001 2001
Thank you very much for any direction.