Forums

This topic is locked

Display all procedures - login user's department

Posted 27 Nov 2006 05:54:39
1
has voted
27 Nov 2006 05:54:39 YC ong posted:
Hello,

I am newbie in programming. I would like to display the procedures depend on the login user’s department. Mean that it will display all procedures which are related to the user’s department like if the user is under Account department, it will show all procedures which created by all departments and choose the Account department as a concern department.

I created two tables which are UserDetail and tblProcedure. The UserDetail table stores all login user info like department. The tblProcedure stores all procedures info like upload file path and concern department. I created individual column for each department in the tblProcedure. I did it this way to store Boolean (1,0) type (checkbox) for each department.
Then I tried to retrieve the user’s department in a recordset. Then pass the department as a variable which the value is same as 1 (checkbox which is checked) into another recordset. I tested it in Dreamweaver recordset. It can retrieve all procedures which are related to the login user’s department. But when I preview in browser, it has error.

Error Type:
Microsoft VBScript runtime (0x800A01A8)
Object required: ''
/internalweb/html/LoginMain_Procedure.asp, line 48

The code for line 48 which I highlight is:
<!--#include file="../Connections/InternalWeb.asp" -->
<%
Dim rsProcedure__Department
rsProcedure__Department = "0"
If (rsDept.Fields.Item("Department".value <> "" Then
rsProcedure__Department = rsDept.Fields.Item("Department".value
End If
%>
<%
Dim rsProcedure
Dim rsProcedure_numRows

Set rsProcedure = Server.CreateObject("ADODB.Recordset"
rsProcedure.ActiveConnection = MM_InternalWeb_STRING
rsProcedure.Source = "SELECT p.*, " + Replace(rsProcedure__Department, "'", "''" + " FROM userdetail u left outer join tblProcedure p on u.employeeno = p.employeeno WHERE " + Replace(rsProcedure__Department, "'", "''" + "='1'"
rsProcedure.CursorType = 0
rsProcedure.CursorLocation = 2
rsProcedure.LockType = 1
rsProcedure.Open()
rsProcedure_numRows = 0
%>

The first recordset, rsDept is as below (In Dreamweaver):

SELECT Department
FROM userdetail
WHERE username = 'MM_ColParam'

Variable:
MM_ColParam 0 Session("MM_Username"

Then I created another recordset called rsProcedure which retrieve the department in rsDept as a variable and equal to 1.

SELECT p.*, Department
FROM userdetail u left outer join tblProcedure p on u.employeeno = p.employeeno
WHERE Department='1'

Variable:
Department 0 rsDept.Fields.Item("Department".value

Any idea on how should I correct this error? Am I correct for the concept to display all procedures which are related to the user’s department?

Hope somebody can help….Urgent….

Thanks,
Yuki

Reply to this topic