Thanks to Manohar for writing the basic code for displaying the managers and
the employees in a tree like structure.
I have adapted the code below but it gives me an error "exception occcured"
after the first recursion.
Any ideas what can be done to make the following code work.
Thanks
<!--#include file="conn.asp"-->
<!-- #include file="adovbs.in c" -->
<%
strUserId = session("UserId ")
set rs = Server.createob ject ("adodb.records et")
SQL = " SELECT HolidayEntitlem ent, EmpName, ManagerName, EmployeeNumber,
FirstName, LastName, left FROM EMPProfile;"
rs.Open SQL, conn, adOpenKeyset, adLockOptimisti c, adCmdText
Set empRs = Rs.Clone()
' Get the top level manager
Rs.Filter = "ManagerNam e = '" & session("userna me") & "'"
' Loop through this recordset
Do While Not Rs.EOF
Response.Write( Rs("FirstName" ) & " " & Rs("LastName") ) & "<br>"
' Recurse for every person directly under this manager
RecurseEmp Rs("EmpName"), 1
Rs.MoveNext
Loop
' The recursion continues until an employee is not
' a manager.
Sub RecurseEmp (ManagerName, level)
' Filter the employee records for people who work
' for this manager directly
empRs.Filter = "ManagerNam e='" & ManagerName & "'"
Do While Not empRs.EOF
' Print spaces for this level
Response.Write " &n bsp;   ; "
' Print this person's name
Response.Write( empRs("FirstNam e") & " " & empRs("LastName ")) & "<br>"
' Recurse for this employee -- check if there are employees
' under this person
' THIS IS WHERE I AM HAVING THE PROBLEM
' IF I COMMENT THE LINE BELOW IT WORKS ALL
' OKAY AND DOES DISPLAY THE EMPLOYEES 1
' LEVEL DOWN FROM THE MAIN
RecurseEmp empRs("EmpName" ), Level + 1
empRs.MoveNext
Loop
End Sub
%>
the employees in a tree like structure.
I have adapted the code below but it gives me an error "exception occcured"
after the first recursion.
Any ideas what can be done to make the following code work.
Thanks
<!--#include file="conn.asp"-->
<!-- #include file="adovbs.in c" -->
<%
strUserId = session("UserId ")
set rs = Server.createob ject ("adodb.records et")
SQL = " SELECT HolidayEntitlem ent, EmpName, ManagerName, EmployeeNumber,
FirstName, LastName, left FROM EMPProfile;"
rs.Open SQL, conn, adOpenKeyset, adLockOptimisti c, adCmdText
Set empRs = Rs.Clone()
' Get the top level manager
Rs.Filter = "ManagerNam e = '" & session("userna me") & "'"
' Loop through this recordset
Do While Not Rs.EOF
Response.Write( Rs("FirstName" ) & " " & Rs("LastName") ) & "<br>"
' Recurse for every person directly under this manager
RecurseEmp Rs("EmpName"), 1
Rs.MoveNext
Loop
' The recursion continues until an employee is not
' a manager.
Sub RecurseEmp (ManagerName, level)
' Filter the employee records for people who work
' for this manager directly
empRs.Filter = "ManagerNam e='" & ManagerName & "'"
Do While Not empRs.EOF
' Print spaces for this level
Response.Write " &n bsp;   ; "
' Print this person's name
Response.Write( empRs("FirstNam e") & " " & empRs("LastName ")) & "<br>"
' Recurse for this employee -- check if there are employees
' under this person
' THIS IS WHERE I AM HAVING THE PROBLEM
' IF I COMMENT THE LINE BELOW IT WORKS ALL
' OKAY AND DOES DISPLAY THE EMPLOYEES 1
' LEVEL DOWN FROM THE MAIN
RecurseEmp empRs("EmpName" ), Level + 1
empRs.MoveNext
Loop
End Sub
%>
Comment