以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  关于移动登录改为从数据库取用户与密码的问题  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=99299)

--  作者:jiterp
--  发布时间:2017/4/17 8:47:00
--  关于移动登录改为从数据库取用户与密码的问题
我参照示例,把下面一段代码

If UserName = "张三" AndAlso Password = "888" Then  \'实际使用的时候,请改为从数据库读取用户名和密码进行比较
    Verified  =
True

ElseIf
Username = "李四" AndAlso Password="999" Then
    Verified  =
True

End
If

改成

Dim dr As DataRow = DataTables("sy_user").Find("[usname] = " & UserName & "")
\'解密字符
Dim mm As String = DecryptText(dr("uspass"),"abc","ys")
If UserName = dr("usname") AndAlso Password = mm Then  \'实际使用的时候,请改为从数据库读取用户名和密码进行比较
    Verified  = True
End If

结果是错的,为什么?

--  作者:gryy
--  发布时间:2017/4/17 8:54:00
--  
Dim dr As DataRow = DataTables("sy_user").Find("[usname] = ‘" & UserName & "’")
--  作者:有点色
--  发布时间:2017/4/17 9:00:00
--  

 Dim dr As DataRow = DataTables("sy_user").Find("[usname] = \'" & UserName & "\'")
\'解密字符
try
    If dr IsNot Nothing Then
        Dim mm As String = DecryptText(dr("uspass"),"abc","ys")
        If UserName = dr("usname") AndAlso Password = mm Then  \'实际使用的时候,请改为从数据库读取用户名和密码进行比较
            Verified  = True
        End If
    End If
catch ex As exception
    msgbox(ex.message)
End try

[此贴子已经被作者于2017/4/17 9:02:01编辑过]

--  作者:有点色
--  发布时间:2017/4/17 9:01:00
--  

 Dim dr As DataRow = DataTables("sy_user").Find("[usname] = \'" & UserName & "\'")
\'解密字符
try
    If dr IsNot Nothing Then
        Dim mm As String = DecryptText(dr("uspass"),"abc","ys")
        If UserName = dr("usname") AndAlso Password = mm Then  \'实际使用的时候,请改为从数据库读取用户名和密码进行比较
            Verified  = True
        End If
    End If
catch ex As exception
    msgbox(ex.message)
End try

[此贴子已经被作者于2017/4/17 9:01:53编辑过]

--  作者:jiterp
--  发布时间:2017/4/17 9:09:00
--  
谢谢老师,在这里让我找到工作的乐趣!