I want a message box to appear if the email/ password is entered incorrectly. I am using an else statement but it doesn't display the message if the login is incorrect.
MyConn = New OleDbConnection
MyConn.ConnectionString = connString
MyConn.Open()
str1 = ("SELECT * FROM [UserData] WHERE [Username] = '" & TxtUserName.Text & "' AND [Password] = '" & TxtPassword.Text & "'")
Dim cmd1 As OleDbCommand = New OleDbCommand(str1, MyConn)
dr = cmd1.ExecuteReader
While dr.Read()
userFound = True
TxtPassword.Text = dr("Username").ToString
TxtUserName.Text = dr("Password").ToString
FirstNameToPass = dr("First Name").ToString
LastNameToPass = dr("Last Name").ToString
AddressToPass = dr("Address").ToString
EmailToPass = dr("Email").ToString
If userFound = True Then
UserAccountView.Show()
Me.Hide()
TxtPassword.Clear()
TxtUserName.Clear()
Else
MsgBox("Login is incorrect")
End If
End While
MyConn.Close()
End If