while (Dr.Read())
{
if (UserPsw == Dr["userpsw"].ToString())
{
Session["U_type"] = Dr["usertype"].ToString();
Session["U_name"] = Dr["username"].ToString();
Session["U_userid"] = Dr["userid"].ToString();
Session["U_Psw"] = Dr["userpsw"].ToString()
{
if (UserPsw == Dr["userpsw"].ToString())
{
Session["U_type"] = Dr["usertype"].ToString();
Session["U_name"] = Dr["username"].ToString();
Session["U_userid"] = Dr["userid"].ToString();
Session["U_Psw"] = Dr["userpsw"].ToString()
解决方案 »
- 怎么得到客户端的机器名
- 有谁做过这样的系统,请给点建议
- 给轮播的图片加超链接
- response.write()
- 麻烦哪位解释一下sql语句
- remove 树节点
- 老板要我一个人三个星期内做一个博客!!
- 一个ASP的问题
- 请问<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">问
- 100分两个问题!!!!!!!
- 自定义了MembershipProvider,如何调用扩展(重载)方法?
- 我用hashtable 更新数据库的问题
就是将“usertype”保存到Session里面啊
SQL代码类似
Select * from username = [xxx]
然后是一个DataReader
循环读记录,如果密码==数据库密码 ,则成功
就把这个人的信息保存到Session 中
conn.Open(); string UserLoginText = "select * from UserTab where username='" + UserName.Trim() + "' and userpower= 1";
SqlCommand cmd = new SqlCommand(UserLoginText, conn);
SqlDataReader Dr = cmd.ExecuteReader();
while (Dr.Read())
{
if (UserPsw == Dr["userpsw"].ToString())
{
Session["U_type"] = Dr["usertype"].ToString();
Session["U_name"] = Dr["username"].ToString();
Session["U_userid"] = Dr["userid"].ToString();
Session["U_Psw"] = Dr["userpsw"].ToString();
SqlConnection conn = new SqlConnection(help.SqlconnStr()); //定义Sqlconnection对象
conn.Open(); string UserLoginText = "select * from UserTab where username='" + UserName.Trim() + "' and userpower= 1"; //SQL语句
SqlCommand cmd = new SqlCommand(UserLoginText, conn); //执行查询
SqlDataReader Dr = cmd.ExecuteReader(); //保存至记录集
while (Dr.Read()) //记录是否有数据---循环
{
if (UserPsw == Dr["userpsw"].ToString()) //UserPsW不知哪来的变量是否=数据库的userpsw
{
Session["U_type"] = Dr["usertype"].ToString(); //
Session["U_name"] = Dr["username"].ToString(); //
Session["U_userid"] = Dr["userid"].ToString(); //
Session["U_Psw"] = Dr["userpsw"].ToString(); //见LS的..