以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  这两个值相等为什么不执行退出呢?  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=9764)

--  作者:dd-zdh
--  发布时间:2011/5/6 19:56:00
--  这两个值相等为什么不执行退出呢?

Dim UserName As String = e.Form.Controls("UserName").Value
Dim s1,s2 As String
Dim cmd As New SQLCommand
Dim dt As DataTable
\'Dim dr As DataRow
cmd.C
If UserName = "" Then
    Messagebox.show("请选择用户!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
    Return
End If
cmd.CommandText = "Select * From {用户表} Where [用户名] = \'" & UserName & "\'"
dt = cmd.ExecuteReader
If dt.DataRows.Count > 0 Then
s1=dt.DataRows(0)("密码")
e.Form.Controls("TextBox2").text=s1
s2=e.form.Controls("TextBox1").text
\'dr = dt.DataRows(0)
If  s1 = s2 Then
\'If e.Form.Controls("PassWord").text = dt.DataRows(0)("密码")  Then
    \'_UserName = UserName
    \'_UserGroup = dt.DataRows(0)("部门")
    e.Form.Close()
Else
\'    Messagebox.show("密码错误!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)

End If
End If


--  作者:狐狸爸爸
--  发布时间:2011/5/6 20:17:00
--  
说明他俩不等嘛
--  作者:dd-zdh
--  发布时间:2011/5/6 20:25:00
--  

我把表里的值都取出来了,和我textbox1.text相等,也不执行退出


--  作者:狐狸爸爸
--  发布时间:2011/5/6 20:30:00
--  

在:

If  s1 = s2 Then

的前面加一行:

 

messagebox.show(s1 = s2 )

 


--  作者:dd-zdh
--  发布时间:2011/5/6 20:51:00
--  
是不等,但我输入的值和取出的值都为11,怎么还显示False呢
--  作者:狐狸爸爸
--  发布时间:2011/5/6 20:57:00
--  

messagebox.show(s1 = s2 )

 

改为

messagebox.show(s1.Length & "|" &  s2.legnth )

 

比较二者的长度,你可能会发现原因,通常是因为前后有空格所致。