Hello Guys,

I am getting this error message and I can't figure out why. can somebody please help. below is the code.

Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click

Dim sql = "SELECT Username,Password FROM Password WHERE Username = "" & txtUsername.Text & "" AND Password = "" & txtPassword.Text & " '"

cmd = New OleDbCommand(sql, conn)

conn.Open()

Dim dr As OleDbDataReader = cmd.ExecuteReader

Try
conn.Open()
Catch ex As Exception
MsgBox(ex.Message)

End Try
Try
If dr.Read = False Then
MessageBox.Show("Authentication Failed...")
Else
MessageBox.Show("Login Successful...")

End If
Catch ex As Exception
MsgBox(ex.Message)

If conn.State <> ConnectionState.Closed Then
conn.Close()

End If

Dim form As New mainfrm
form.Show()
End Try
End Sub

This question has already been answered. Start a new discussion instead.