Building list of companies and employees in vbscript

We are building an event attendee list and for this particular version, we want to show a parent company's sub-companies, with attendees for each sub-company listed below the subcompany name.  Something like:

Attendees for A Company
B Company
  Attendee 1
  Attendee 2
C Company
  Attendee 3
D Company
  Attendee 4
  Attendee 5
  Attendee 6

What is the most efficient way to build this?  In previous instances of addressing anything like this, we have known the number of subcompanies and coded accordingly, but for this project, some of the overall companies will have many sub-companies and some will have none.

We have put together code that renders a sub-company and it's employees:
<% 
While ((Repeat2__numRows <> 0) AND (NOT companydetailResult.EOF)) 
%>
      <tr>
        <td><%=(companydetailResult.Fields.Item("first_name").Value)%>&nbsp;<%=(companydetailResult.Fields.Item("last_name").Value)%>, <%=(companydetailResult.Fields.Item("title").Value)%></td>
      </tr>
      <% 
  Repeat2__index=Repeat2__index+1
  Repeat2__numRows=Repeat2__numRows-1
  companydetailResult.MoveNext()
Wend
%>

Open in new window


The query that gives us the info is
"SELECT parent_org_name, org_name, first_name, last_name, title FROM dbo.DB_Registrants WHERE parent_org_id = ? ORDER BY last_name ASC" 

Open in new window


But we are kind of stumped on how to wrap the loop above to parse through each of the sub-companies (org_name).

All suggestions are greatly appreciated!
chipsterva69Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ryan ChongCommented:
so i believe your intention is to add the Company name and try to segregate the attendees accordingly?

if yes you may customize this:
<%
c = ""
 
While ((Repeat2__numRows <> 0) AND (NOT companydetailResult.EOF)) 
%>
<%
   if companydetailResult.Fields.Item("org_name").Value <> c then
          c = companydetailResult.Fields.Item("org_name").Value
	  response.write("<tr><td>" & c & "</td></tr>")          
   end if
%>      

      <tr>
        <td><%=(companydetailResult.Fields.Item("first_name").Value)%>&nbsp;<%=(companydetailResult.Fields.Item("last_name").Value)%>, <%=(companydetailResult.Fields.Item("title").Value)%></td>
      </tr>
      <% 
  Repeat2__index=Repeat2__index+1
  Repeat2__numRows=Repeat2__numRows-1
  companydetailResult.MoveNext()
Wend
%>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
chipsterva69Author Commented:
Worked straight out of the box! Thanks a million, @Ryan Chong - very much appreciated!
0
chipsterva69Author Commented:
One other thing to add, no reflection on the answer, but for folks that may refer to this solution later on -

The order of attendees in the result is dependent on the query results, so make sure the query returns them in the order you want them to be displayed.  It took me a few tries to figure that part out...

Final query resembled this -

SELECT parent_org_name, org_name, first_name, last_name, title FROM dbo.DB_Registrants WHERE parent_org_id = ? ORDER BY org_name ASC, last_name ASC

Open in new window


Thanks again @Ryan!
0
Ryan ChongCommented:
glad could make some helps here and tks for sharing additional info in comment: ID: 40957132 for whoever seeing this post, cheers
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.