如何在asp.net中使用用户角色创建登录

时间:2013-07-15 17:56:16

标签: asp.net

有两个表,一个是使用电子邮件ID,用户名,密码,名称登录,其中电子邮件ID是主键,第二个表是Employee_role,其中id为主键,emp_role和emailid作为登录电子邮件ID的外键。

这里的条件是emprole有admin和任何用户首先登录它 检查该emaild id是否在employee_role中,如果是,它将指向" admin page"如果不是,它没有找到任何电子邮件,它将指向"访客页面"

请我更新鲜帮助我...

1 个答案:

答案 0 :(得分:1)

Please i am fresher do help me...

我们都在某个地方开始,所以没问题。我知道我看到你有很多事。那是因为你自己并没有真正尝试过,也没有分享你尝试过的东西。以下是您的问题的一些一般性建议。你需要再多看一眼,然后回答问题。我必须做出一些假设才能让你从这里开始。

There are two tables one is Login with Email id, username, password, name and where email id is primary key and the second table is Employee_role with id as primary key, emp_role, and emailid as foreign key of login email id.

我认为您不需要创建这些表的特定帮助。您显然知道外键和主键约束。

here the condition is in emprole there is admin and whenver any user log in it first check if that emaild id is in employee_role if yes it would direct to "admin page" if otherwise it didnot find any emailid it will direct to "guest page"

这是在SQL中实现这一目标的一种方法:

SELECT l.email, l.userid, l.password, 
Case when r.emp_role is not null then 'admin.aspx' else 'guest.aspx' END as 
'TransferPage'
from dbo.Login l
LEFT OUTER JOIN dbo.employee_role r on l.emailid = r.emailid
WHERE email = @email  --Assumes you pass in parameter @email

获取此查询的结果,并将返回的查询的密码与输入的文本的密码进行比较,如果有效,则执行

response.redirect

到查询返回的页面。

希望这会有所帮助......