Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/mongodb/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vb.net 登录过程问题 公共类登录 Dim conn作为MySqlConnection 作为MySqlDataReader的Dim读取器 Dim cmd作为MySqlCommand 将审核设置为字符串 像线一样模糊 Dim connectiontime,以字符串形式活动 作为字符串的模糊尝试 Dim server As String=“server=127.0.0.1;user=root;database=spilibrary” 私有子按钮1\u单击(发送者作为对象,e作为事件参数)处理btnLogin。单击 作为字符串的Dim语句 Dim Userrole作为字符串 conn=新的MySQL连接 conn.ConnectionString=服务器 康涅狄格州公开赛 statement=“select*from user where Username='”&Username.Text&“and Password=BINARY'”&Password.Text&“” cmd=新的MySqlCommand(语句,conn) Reader=cmd.ExecuteReader 尝试 Dim被发现为布尔值 边读边读 找到=真 Userrole=Reader.GetString(“Userrole”) connectiontime=Reader.GetString(“connectiontime”) 尝试次数=Reader.GetString(“尝试次数”) 如果Userrole=“Administrator”和connectiontime=“Now”或connectiontime=TimeOfDay.ToString(“HH:mm:ss”),则 MsgBox(“由于多次尝试失败,您的帐户已被阻止”,vbCritical,“系统消息”) ElseIf Userrole=“library”和connectiontime“Now”和connectiontime>=TimeOfDay.ToString(“HH:mm:ss”)然后 MsgBox(“由于多次尝试失败,您的帐户已被阻止”,vbCritical,“系统消息”) 其他的 MsgBox(“您的帐户由于多次尝试失败而被阻止”,vbCritical,“系统消息”) 如果结束_Vb.net - Fatal编程技术网

Vb.net 登录过程问题 公共类登录 Dim conn作为MySqlConnection 作为MySqlDataReader的Dim读取器 Dim cmd作为MySqlCommand 将审核设置为字符串 像线一样模糊 Dim connectiontime,以字符串形式活动 作为字符串的模糊尝试 Dim server As String=“server=127.0.0.1;user=root;database=spilibrary” 私有子按钮1\u单击(发送者作为对象,e作为事件参数)处理btnLogin。单击 作为字符串的Dim语句 Dim Userrole作为字符串 conn=新的MySQL连接 conn.ConnectionString=服务器 康涅狄格州公开赛 statement=“select*from user where Username='”&Username.Text&“and Password=BINARY'”&Password.Text&“” cmd=新的MySqlCommand(语句,conn) Reader=cmd.ExecuteReader 尝试 Dim被发现为布尔值 边读边读 找到=真 Userrole=Reader.GetString(“Userrole”) connectiontime=Reader.GetString(“connectiontime”) 尝试次数=Reader.GetString(“尝试次数”) 如果Userrole=“Administrator”和connectiontime=“Now”或connectiontime=TimeOfDay.ToString(“HH:mm:ss”),则 MsgBox(“由于多次尝试失败,您的帐户已被阻止”,vbCritical,“系统消息”) ElseIf Userrole=“library”和connectiontime“Now”和connectiontime>=TimeOfDay.ToString(“HH:mm:ss”)然后 MsgBox(“由于多次尝试失败,您的帐户已被阻止”,vbCritical,“系统消息”) 其他的 MsgBox(“您的帐户由于多次尝试失败而被阻止”,vbCritical,“系统消息”) 如果结束

Vb.net 登录过程问题 公共类登录 Dim conn作为MySqlConnection 作为MySqlDataReader的Dim读取器 Dim cmd作为MySqlCommand 将审核设置为字符串 像线一样模糊 Dim connectiontime,以字符串形式活动 作为字符串的模糊尝试 Dim server As String=“server=127.0.0.1;user=root;database=spilibrary” 私有子按钮1\u单击(发送者作为对象,e作为事件参数)处理btnLogin。单击 作为字符串的Dim语句 Dim Userrole作为字符串 conn=新的MySQL连接 conn.ConnectionString=服务器 康涅狄格州公开赛 statement=“select*from user where Username='”&Username.Text&“and Password=BINARY'”&Password.Text&“” cmd=新的MySqlCommand(语句,conn) Reader=cmd.ExecuteReader 尝试 Dim被发现为布尔值 边读边读 找到=真 Userrole=Reader.GetString(“Userrole”) connectiontime=Reader.GetString(“connectiontime”) 尝试次数=Reader.GetString(“尝试次数”) 如果Userrole=“Administrator”和connectiontime=“Now”或connectiontime=TimeOfDay.ToString(“HH:mm:ss”),则 MsgBox(“由于多次尝试失败,您的帐户已被阻止”,vbCritical,“系统消息”) ElseIf Userrole=“library”和connectiontime“Now”和connectiontime>=TimeOfDay.ToString(“HH:mm:ss”)然后 MsgBox(“由于多次尝试失败,您的帐户已被阻止”,vbCritical,“系统消息”) 其他的 MsgBox(“您的帐户由于多次尝试失败而被阻止”,vbCritical,“系统消息”) 如果结束,vb.net,Vb.net,有人请帮我做这个。。当我点击登录按钮时,它总是读取我输入的第一条if-else语句,即Userrole=“administrator”,即使我登录了我的图书管理员Userrole。当我尝试切换它们时,它读取的是图书管理员用户角色,而不是管理员,即使我记录了我的管理员用户角色。。在我的数据库中,它们被声明为正确的。所以可能是密码。谢谢你试着在你的身体状况中使用括号,让它更清楚。像这样: Public Class login Dim conn As MySqlConnection D

有人请帮我做这个。。当我点击登录按钮时,它总是读取我输入的第一条if-else语句,即Userrole=“administrator”,即使我登录了我的图书管理员Userrole。当我尝试切换它们时,它读取的是图书管理员用户角色,而不是管理员,即使我记录了我的管理员用户角色。。在我的数据库中,它们被声明为正确的。所以可能是密码。谢谢你

试着在你的身体状况中使用括号,让它更清楚。像这样:

Public Class login
    Dim conn As MySqlConnection
    Dim Reader As MySqlDataReader
    Dim cmd As MySqlCommand
    Dim audit As String
    Dim faudit As String
    Dim connectiontime, active As String
    Dim attempts As String
    Dim server As String = "server=127.0.0.1;user=root;database=spilibrary"
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles btnLogin.Click
        Dim statement As String
        Dim Userrole As String
        conn = New MySqlConnection
        conn.ConnectionString = server
        conn.Open()
        statement = "select * from user where Username = '" & username.Text & "' and Password = BINARY '" & password.Text & "'"
        cmd = New MySqlCommand(statement, conn)
        Reader = cmd.ExecuteReader

        Try
            Dim found As Boolean
            While Reader.Read
                found = True
                Userrole = Reader.GetString("Userrole")
                connectiontime = Reader.GetString("connectiontime")
                attempts = Reader.GetString("attempts")
                If Userrole = "Administrator" And connectiontime = "Now" Or connectiontime <= TimeOfDay.ToString("HH:mm") Then
                    MsgBox("Welcome Admin", MsgBoxStyle.Information, "System message")
                    mainform.Show()
                    mainform.Maintenancebtn.Enabled = True
                    mainform.level1.Text = Userrole
                    'Me.Close()
                    Reader.Close()
                    cmd = New MySqlCommand("update user set attempts = '" & "0" & "', connectiontime='" & "Now" & "' where Username='" & username.Text & "'", conn)
                    Reader = cmd.ExecuteReader
                ElseIf Userrole = "Librarian" And connectiontime = "Now" Or connectiontime <= TimeOfDay.ToString("HH:mm:ss") Then
                    MsgBox("Welcome Librarian", MsgBoxStyle.Information, "System Message")
                    'mainform.Maintenancebtn.Enabled = False
                    mainform.Show()
                    mainform.level1.Text = Userrole
                    ' Me.Close()
                    'OPAC.show()
                    Reader.Close()
                    cmd = New MySqlCommand("update user set attempts ='" & "0" & "', connectiontime ='" & "Now" & "' where Username='" & username.Text & "'", conn)
                    Reader = cmd.ExecuteReader
                ElseIf Userrole = "Administrator" And connectiontime <> "Now" And connectiontime >= TimeOfDay.ToString("HH:mm:ss") Then
                    MsgBox("You're Account has been blocked because of multiple failed attempts", vbCritical, "System Message")
                ElseIf Userrole = "Librarian" And connectiontime <> "Now" And connectiontime >= TimeOfDay.ToString("HH:mm:ss") Then
                    MsgBox("Your Account has been blocked because of multiple failed attempts", vbCritical, "System Message")
                Else
                    MsgBox("You're Account whas been blocked because of multiple failed attempts", vbCritical, "System Message")
                End If

如果Userrole=“Administrator”和also(connectiontime=“Now”OrElse connectiontime@Glendonolo没关系。它的优先级高于或高于,因此,如果您不想这样做,则需要使用括号来覆盖它。始终使用参数以避免Sql注入。您只会在数据访问后对代码进行错误保护。您假设连接或检索数据时不会出现错误。
connectiontimeing现在很好,多亏了jon Roberts先生,我在jon的代码中没有提到任何参数。我说的是命令参数。如果你不使用它们,你会把数据库置于危险之中。
If Userrole = "Administrator" AndAlso (connectiontime = "Now" OrElse connectiontime <= TimeOfDay.ToString("HH:mm")) Then
connectiontime <= TimeOfDay.ToString("HH:mm")