my login code works fine but the it gives me problems when the username and password in questin are not on the first row in the datatable. This is because when the code in debug mode, I took the time to check the contents of the datatable using the datatable visualiser and I actually noticed that the username and password are there in the datatable but are not just in the first position , what can I do to correct this error.
Dim STRsql As String = "SELECT reference,UserName,UserPassword,UserCompany FROM Users WHERE UserName = '" & cmbUsername.Text & "' "
'Conn.Open()
Dim dTable As DataTable = New DataTable
Dim dscmd As New OleDbDataAdapter(STRsql, Conn)
dscmd.Fill(dTable)
Conn.Close()
If dTable.Rows(0)("UserName") = cmbUsername.Text Then
If dTable.Rows(0)("UserPassword") = txtPassword.Text Then
comm1.LogINUserName = dTable.Rows(0)("UserName").ToString
'MsgBox(comm1.LogINUserName)
frmMenu.Show()
Else
MsgBox("Wrong Password and/or Username") '***In the case of wrong Password
Exit Sub
End If
Else
MsgBox("Wrong Password and/or Username") '***In the case of wrong UserName
Exit Sub
End If