Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select from Database by name and group 1

Status
Not open for further replies.

Billybonga

IS-IT--Management
Jun 22, 2002
72
GB
Hi,

I'm workign on a project where I have hit a stumbling block with an SQL query.
I want to search a MS Access database table (tbl_company) which contains Usernames & Department for every employee.

I have the system working so far in that search the database and determine if a user is in a table -

Code:
<%
set objconn = server.createobject("adodb.connection")
objconn.open "william"
set objrec = server.createobject("adodb.recordset")
  ' Retrieve the Windows Domain Username
username = request.servervariables("LOGON_USER")
    'Search for records of Username
set RS = objconn.execute("select * from tbl_people where Name = '"&username&"' ")
        if RS.EOF = False then
     'If Username already exist then redirect - 
       response.redirect "block.asp"
    End If
%>

but want i want to try to figure out now is - detect what group the user is in, and redirect them by their group e.g.
User loads the .asp page, check what group their username is in, if in administration - redirect to admin.asp, if in IT redirect to it.asp etc

Any help is appreciated.

 

How is the group information stored in the database? is it another field in the tbl_people? if so then try that

Code:
<%
set objconn = server.createobject("adodb.connection")
objconn.open "william"
set objrec = server.createobject("adodb.recordset")
  ' Retrieve the Windows Domain Username
username = request.servervariables("LOGON_USER")
    'Search for records of Username
set RS = objconn.execute("select * from tbl_people where Name = '"&username&"' ")
        if RS.EOF = False then
     'If Username already exist then redirect - 
       if rs("group") = "admin" then
         response.redirect "admin.asp"
       elseif rs("group") = "it" then
         response.redirect "it.asp"
       end if
    End If
%>

if it's on another table you might want to join the two tables. if you give us more details of your database structure we will give you a more detailed answer.

N

 
cheers nicsin -

Usernames and groups are within the same table so what you have posted should work perfectly.

thanks for your help _ i'll give this a shot and let you know the outcome
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top