扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
作者:佚名 来源:论坛 2007年11月8日
关键字: Windows
//IsRegUserOk函数:判断用户是否已经注册和密码是否正确 public bool IsRegUserOk() { string name=TextBoxName.Text.Trim(); string pwd=TextBoxPassword.Text.Trim(); //建立/打开数据库连接 SqlConnection conn=new SqlConnection(); conn.ConnectionString="server=(local);uid=sa;pwd=;database=jxdb"; conn.Open(); //建立sql字符串 string sql="select * from reg where name='"+name+"'"; SqlDataReader dr; SqlCommand cmd=new SqlCommand(sql,conn); dr=cmd.ExecuteReader(); //保留用户注册与否信息 bool isRegUserExist=dr.Read(); //关闭DataReader dr.Close(); //取得用户名的密码 string sqlBoth="select * from reg where name='"+name+"'"; sqlBoth+="and pwd='"+pwd+"'"; SqlCommand cmdBoth=new SqlCommand(sqlBoth,conn); SqlDataReader drBoth; drBoth=cmdBoth.ExecuteReader(); //保留用户名+密码同时存在信息 bool isBothExist=drBoth.Read(); //关闭DataReader drBoth.Close(); conn.Close(); //判断用户是否注册 if(!isRegUserExist) { Response.Write("<script>alert('此用户尚未注册!')"); return false; } //判断用户名与密码是否一致 else if(!isBothExist) { Response.Write("<script>alert('用户名和密码不一致,不能进入!')"); return false; } else return true; } |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者