Rss & SiteMap
Foxtable(狐表) http://www.foxtable.com
请教:
在窗口中比较输入的密码和读出来的密码比较代码如下
e.Form.Controls("txtpwd").Value = dr("userPwd") 但是两个字符串不相等,是怎么回事呢!
全部代码是这样的:
Dim uName As String = e.Form.Controls("txtName").Value
Dim cmd As New SQLCommand
Dim dt As DataTable
Dim dr As DataRow
cmd.C
If uName = "" Then
Messagebox.show("请选择用户!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
Return
End If
cmd.CommandText = "Select * From {userInfo} Where [userID] = '" & uName & "'"
dt = cmd.ExecuteReader
dr = dt.DataRows(0)
If e.Form.Controls("txtpwd").Value = dr("userPwd") Then
'_UserName = UserName
'_UserGroup = dr("userDES")
MessageBox.Show("登录成功!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
Else
Messagebox.show("密码错误!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
End If
计算机是不会撒谎的,等于就是等于,不能于就是不等于。
加行代码,目测两个值分别是什么,然后再比较。
messagebox.Show(e.Form.Controls("txtpwd").Value & "|" & dr(userPwd))
If e.Form.Controls("txtpwd").Value = dr("userPwd") Then
再比较长度:
messagebox.Show(len(e.Form.Controls("txtpwd").Value) & "|" & len(dr(userPwd)))
确实是两个长度不一样!那么怎样去比较呢
确实是存在空格,我用了dr("userPwd").trim() 就可以了,谢谢提示!