i have 2 web pages one for login and other index.
for login 3 cols are defined in database table. name, password, and role
i want that when user loges in a session is created that saves the role of user(means it takes the role from database table for that particular user). after loging in to the index pages the role session is to be checked whether the user is user or admin. how is it possible. please help me.
Loading
Morcos AdelPosted Jun 26, 2011, 7:42 AM
sqlcommand command=new sqlcommand();
command.connection=connection;
command.commandType=CommandType.Text;
command.commandText="select role from [your Tablename] where name='name'";
sqlDatareader Dr=command.ExecuteReader();
while (Dr.read())
{
String x=Dr["role"].tostring();
}
// Now String x has The Value Returned from the query
Session["Role"]=x;
// Now Session["Role"] has the Value of x
you can check on it in the Index Page
i hope this helps...
saifullah khanPosted Jun 26, 2011, 7:14 AM
Morcos AdelPosted Jun 26, 2011, 6:09 AM
or
you can use the ASP.NET SQL Server Registration Tool which will give you more features to use.