I’m doing a login page using C# and my login works perfectly fine, one problem though is that I want to check if the person logged in has administrative rights or not so that I can direct them to a correct page. If for example Dorothy logged in I must direct her to an admin page. When I do my select statement I get different errors, can someone pls help with the correct SQL statement? I have three tables:
tblUser
| UserId |
Username |
Password |
| 1001 |
Dorothy |
12345 |
| 1001 |
Jane |
78965 |
|
|
|
tblRole
| RoleId |
RoleDescription |
| 1111 |
Administrator |
| 1112 |
Floor Manager |
| 1113 |
Sales Director |
tblUserRolelink
| UserId |
RoleId |
| 1001 |
1111 |
| 1001 |
1113 |
fangza lro2 pointsPosted Nov 15, 2006, 11:06 PM EST
where u.Username=xxx and u.Password=xxx
Is this SQL sentence OK?
Kheen On Cheah9 pointsPosted Nov 16, 2006, 12:18 AM EST
try
select
A.Username
, C.RoleDescription
from
tblUser A
, tblUserRolelink B
, tblRole C
where
B.UserId = A.UserId
and C.RoleId = B.RoleId
and A.Username = xxxx
;
Dorothy9 pointsPosted Nov 16, 2006, 2:48 AM EST
I had the similar select statement but it keeps on returning positive even if the user logged in doesn't have admin rights...Unless there's another method.
Select r.RoleId, u.UserId, sys.RoleId, sys.UserId From Role r, User u, UserRoleLink sys
Where r.RoleId = sys.roleId AND u.UserId = sys.UserId AND r.RoleDesc = 'Managing Director'
Kheen On Cheah9 pointsPosted Nov 16, 2006, 2:46 PM EST
Dorothy9 pointsPosted Nov 20, 2006, 8:14 PM EST
solution and it worked perfectly.