本文介绍了如何使用角色和会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我想要两件事。首先我要使用此代码创建会话,其次我想使用角色所以想要改变我必须在这个代码中做这两件事。 请帮助我为此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 thatprotected 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); } }推荐答案 这篇关于如何使用角色和会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
07-30 05:34