如何使用角色和会话 [英] how to use roles and session
本文介绍了如何使用角色和会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想要两件事。首先我要使用此代码创建会话,其次我想使用角色所以想要改变我必须在这个代码中做这两件事。
请帮助我为此
i want two things.First i want to create session using this code and second i want to use roles so want changing i have to made in this code to do these two things.
please help me for that
protected void Button1_Click(object sender, EventArgs e)
{
try
{
SqlConnection con = new SqlConnection(@"Data Source=LENOVO-41B3F2CE\SQLEXPRESS;Initial Catalog=IMS;Integrated Security=True;Pooling=False");
string query = "SELECT [user].* FROM [user] where u_name='" + txtusername.Text + "' and pwd='" + txtpassword.Text + "'";
SqlCommand com = new SqlCommand(query, con);
con.Open();
if (txtusername.Text == "admin")
{
if (com.ExecuteReader().HasRows)
{
Response.Redirect("allinventory.aspx");
Label3.Text = "successfully";
}
else
{
Label3.Text = "not successfully";
txtusername.Text = "";
txtpassword.Text = "";
}
}
else if (txtusername.Text == "User")
{
if (com.ExecuteReader().HasRows)
{
Response.Redirect("userinventory.aspx");
Label3.Text = "successfully";
}
else
{
Label3.Text = "not successfully";
txtusername.Text = "";
txtpassword.Text = "";
}
}
con.Close();
}
catch (Exception ex)
{
Console.Write("" + ex.Message);
}
}
推荐答案
查看我最近回答的问题< a href =http://www.codeproject.com/Answers/586143/Regardingplusacessplusinformation#answer>这里
Have look at my recently answered question here
这篇关于如何使用角色和会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文