Forums

This topic is locked

WHERE clause containing a session variable

Posted 16 Apr 2001 20:52:05
1
has voted
16 Apr 2001 20:52:05 Mark Pickus posted:
I successfully used Hiran de Silva's UD tutorials to create login pages and secure individual pages.
However, I have one additional need: to restrict the records retrieved from the database based on the "svUserID" variable.
I work for a school district and am creating a site where teachers can view / modify records for their students only. All records in the Access database are tagged in the TeacherID field with the teacher's user id which should match the "svUserID" exactly.
The following is the code that retrieves the records (ALL records)
RdgRecords.Source = "SELECT * FROM T_RdgRecords"
What is the syntax to add a WHERE clause that will restrict records to those that match the TeacherID field?
Thanks, Mark Pickus
Student Data Manager
Oak Park Public Schools, Oak Park, IL

Replies

Replied 17 Apr 2001 16:08:31
17 Apr 2001 16:08:31 Quy To replied:
I dont know what version of UD you're using. Here's what we'd do in UD4(usually when we want to customize "my_page.asp" or "my_courses.asp" for each user who just logged in.
If you use UD4's Log-in behavior, it will create a session called MM_Username. MM_Username is based on the user_id field in our database. In your case, since you follow Hiran's tutorial, your user_id is TeacherID and session name is svUserID.
Anyway, here's how to set it up:
-------------------------------------------
SELECT TeacherID, TeachFirst, TeacherLast
FROM TeachersTable
WHERE TeacherID = 'MMColParam'
-------------------------------------------
Then, down at VARIABLES part, enter MMColParam as NAME, enter a DEFAULT VALUE (1, or a TeacherID). Fill RUN-TIME VALUE as
Session("svUserID"

------------------------------------------
That's it. You can do this in either Simple or Advance Mode.

Hope this's what you wanted, and it helps.

qto
www.DUresources.com

Edited by - qto on 04/17/2001 16:14:15

Reply to this topic