Mysql VB.NET中的登录表单有问题

Mysql VB.NET中的登录表单有问题,mysql,vb.net,Mysql,Vb.net,好的,这是我在vb.net中工作的程序的一部分,它应该做的是进入我的MYSQL数据库,检查用户在数据库中输入的与用户名/密码匹配的内容(简单登录),但它不工作,它在第一个if语句处停止,我不知道为什么,但每次都会被捕获。我每隔一行输入messagesbox来解决这个问题,所以我知道if语句有问题 Dim rdr As MySqlDataReader = Nothing Myconnection = "Server=LocalHost; database=vb; user=root

好的,这是我在vb.net中工作的程序的一部分,它应该做的是进入我的MYSQL数据库,检查用户在数据库中输入的与用户名/密码匹配的内容(简单登录),但它不工作,它在第一个if语句处停止,我不知道为什么,但每次都会被捕获。我每隔一行输入messagesbox来解决这个问题,所以我知道if语句有问题

    Dim rdr As MySqlDataReader = Nothing
    Myconnection = "Server=LocalHost; database=vb; user=root; password=tro63jans; "
    db_con.ConnectionString = Myconnection
    Dim cmd As New MySqlCommand("SELECT * FROM login", db_con)


    Try
        db_con.Open()
        rdr = cmd.ExecuteReader()

        Dim found As Boolean = False

        While rdr.Read()

            If username.ToUpper() = DirectCast(rdr("username"), String) Then

                If password = DirectCast(rdr("password"), String) Then

                    found = True
                    MessageBox.Show("you are log in")
                    Exit While

                Else

                    MessageBox.Show("username and password do not match", "Error")
                    txtpassword.Focus()

                End If

                If found Then

                    MessageBox.Show("user name not found", "error")
                    txtusername.Focus()
                    txtpassword.Focus()
                    Exit While

                End If

            Else

                If found Then
                    MessageBox.Show("User name not found", "error")
                    txtusername.Focus()

                End If
            End If
        End While

请粘贴你捕捉到的异常,我没有发现异常,这是唯一的办法,我知道问题出在哪里,因为我每行都放了一个消息框。显示(1)然后是2,依此类推,它停在if站。但我不知道为什么。如果它流行起来,就有一个例外。例如,您可以在catch块中放置MsgBox(ex.Message)和MsgBox(ex.StackTrace)来查看它。此外,您似乎还需要学习调试。还有,为什么要获取所有用户?