わかりましたので、これは私がvb.netで取り組んでいるプログラムの一部です。MYSQLデータベースにアクセスして、ユーザーが入力したものがデータベースのユーザー名/パスワードと一致するかどうかを確認します(単純なログイン)が、機能していません。最初のifステートメントで停止しています。理由はわかりませんが、毎回キャッチに行きます。私は問題を解決するためにmessagesboxの1行おきに入れているので、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