以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  为什么会编译错误呢?  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=138313)

--  作者:ygg8310
--  发布时间:2019/7/28 12:09:00
--  为什么会编译错误呢?
Dim UserName As String = e.Cookies("username") \'从cookie中获取用户名
Dim Password As String = e.Cookies("password") \'从cookie中获取用户密码
If e.Path = "logon.htm" \'如果是通过登录页面访问,从PostValues即可中提取用户名和密码
    If e.PostValues.ContainsKey("username") AndAlso e.PostValues.ContainsKey("password")  Then
        UserName = e.PostValues("username")
        Password = e.PostValues("password")
    End If
End If
If UserName = DataTables("用户表").find("username=\'" & e.PostValues("username") & "\'") AndAlso Password = DataTables("用户表").find("password =\'" & e.PostValues("password ") & "\'")  \'实际使用的时候,请改为从数据库读取用户名和密码进行比较
    Verified  = True
ElseIf Username = "李四" AndAlso Password="999" Then
    Verified  = True
End If


--  作者:有点蓝
--  发布时间:2019/7/28 22:25:00
--  
Dim UserName As String = e.Cookies("username") \'从cookie中获取用户名
Dim Password As String = e.Cookies("password") \'从cookie中获取用户密码
If e.Path = "logon.htm" \'如果是通过登录页面访问,从PostValues即可中提取用户名和密码
    If e.PostValues.ContainsKey("username") AndAlso e.PostValues.ContainsKey("password")  Then
        UserName = e.PostValues("username")
        Password = e.PostValues("password")
    End If
End If
dim dr as datarow = DataTables("用户表").find("username=\'" & e.PostValues("username") & "\'")
if dr isnot nothing then
    Verified   = ( Password  = dr("password"))
ElseIf Username = "李四" AndAlso Password="999" Then
    Verified  = True
else
    Verified   = false
end if

--  作者:ygg8310
--  发布时间:2019/7/29 10:22:00
--  
编译错误 “dr”在封闭块中隐藏变量,错误代码
dim dr as datarow = DataTables("用户表").find("username=\'" & e.PostValues("username") & "\'")

--  作者:有点蓝
--  发布时间:2019/7/29 10:49:00
--  
事件重复定义了dr这个相同名称的变量,请改名
--  作者:ygg8310
--  发布时间:2019/7/29 12:11:00
--  
可以了,完美解决,谢谢老师!图片点击可在新窗口打开查看