J
JP SIngh
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.inc" -->
<%
strUserId = session("UserId")
set rs = Server.createobject ("adodb.recordset")
SQL = " SELECT HolidayEntitlement, EmpName, ManagerName, EmployeeNumber,
FirstName, LastName, left FROM EMPProfile;"
rs.Open SQL, conn, adOpenKeyset, adLockOptimistic, adCmdText
Set empRs = Rs.Clone()
' Get the top level manager
Rs.Filter = "ManagerName = '" & session("username") & "'"
' 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 = "ManagerName='" & ManagerName & "'"
Do While Not empRs.EOF
' Print spaces for this level
Response.Write " "
' Print this person's name
Response.Write(empRs("FirstName") & " " & 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.inc" -->
<%
strUserId = session("UserId")
set rs = Server.createobject ("adodb.recordset")
SQL = " SELECT HolidayEntitlement, EmpName, ManagerName, EmployeeNumber,
FirstName, LastName, left FROM EMPProfile;"
rs.Open SQL, conn, adOpenKeyset, adLockOptimistic, adCmdText
Set empRs = Rs.Clone()
' Get the top level manager
Rs.Filter = "ManagerName = '" & session("username") & "'"
' 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 = "ManagerName='" & ManagerName & "'"
Do While Not empRs.EOF
' Print spaces for this level
Response.Write " "
' Print this person's name
Response.Write(empRs("FirstName") & " " & 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
%>