By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,017 Members | 1,238 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,017 IT Pros & Developers. It's quick & easy.

need help

P: 19
whats wrong with my codes? i need to login using two textfields: txtuser for the username and txtpass for the password. i am using ado and ms access as a database. when i tried to enter with a long password i always get these error "either bof or eof is true." and when i try to enter with a right password but with a wrong username, i successfully logged in. so what's wrong? hope you can help me with this.

This is my codes:

Private Sub cmdLogin_Click()

'check for null password
If txtuser = "" Then
MsgBox "User Name required.", vbExclamation
txtuser.SetFocus
Exit Sub
End If

'check for null password
If txtpass = "" Then
MsgBox "Password required.", vbExclamation
txtpass.SetFocus
Exit Sub
End If

Set conn = New ADODB.Connection
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & app.Path & "\password.mdb;Persist Security Info=False"

Set rs = New ADODB.Recordset
msql = ""
msql = "Select * From pass " & _
"where password like '" & txtpass.Text & "%'"
Set rs = conn.Execute(msql, , adCmdText)

If rs.RecordCount <> 0 Then
msql = UCase(Trim(rs("username")))
End If

rs.Close
Set rs = Nothing

If msql <> UCase(Trim(txtuser)) Then
MsgBox "Incorrect password", vbExclamation
Else
MsgBox "Right Password!", vbExclamation
Unload frmLogin

frmSplash.Show

'Load (but don't show) the project's main form.
Load frmGSOMain

Do
DoEvents
Loop Until frmSplash.ReadyToClose

'Show the project's main form & get rid of the splash screen.
frmGSOMain.Show
Unload frmSplash
Set frmSplash = Nothing
txtpass = Empty
End If


End Sub
Jan 3 '07 #1
Share this Question
Share on Google+
2 Replies


P: 19
--------------------------------------------------------------------------------

whats wrong with my codes? i need to login using two textfields: txtuser for the username and txtpass for the password. i am using ado and ms access as a database. when i tried to enter with a long password i always get these error "either bof or eof is true." and when i try to enter with a right password but with a wrong username, i successfully logged in. so what's wrong? hope you can help me with this.

This is my codes:
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdLogin_Click()
  2.  
  3. 'check for null password
  4. If txtuser = "" Then
  5. MsgBox "User Name required.", vbExclamation
  6. txtuser.SetFocus
  7. Exit Sub
  8. End If
  9.  
  10. 'check for null password
  11. If txtpass = "" Then
  12. MsgBox "Password required.", vbExclamation
  13. txtpass.SetFocus
  14. Exit Sub
  15. End If
  16.  
  17. Set conn = New ADODB.Connection
  18. conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & app.Path & "\password.mdb;Persist Security Info=False"
  19.  
  20. Set rs = New ADODB.Recordset
  21. msql = ""
  22. msql = "Select * From pass " & _
  23. "where password like '" & txtpass.Text & "%'"
  24. Set rs = conn.Execute(msql, , adCmdText)
  25.  
  26. If rs.RecordCount <> 0 Then
  27. msql = UCase(Trim(rs("username")))
  28. End If
  29.  
  30. rs.Close
  31. Set rs = Nothing
  32.  
  33. If msql <> UCase(Trim(txtuser)) Then
  34. MsgBox "Incorrect password", vbExclamation
  35. Else
  36. MsgBox "Right Password!", vbExclamation
  37. Unload frmLogin
  38.  
  39. frmSplash.Show
  40.  
  41. 'Load (but don't show) the project's main form.
  42. Load frmGSOMain
  43.  
  44. Do
  45. DoEvents
  46. Loop Until frmSplash.ReadyToClose
  47.  
  48. 'Show the project's main form & get rid of the splash screen.
  49. frmGSOMain.Show
  50. Unload frmSplash
  51. Set frmSplash = Nothing
  52. txtpass = Empty
  53. End If
  54.  
  55.  
  56. End Sub
  57.  
Jan 3 '07 #2

Expert 5K+
P: 8,434
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdLogin_Click()
  2.  
  3. ' Check for null password
  4. If txtuser = "" Then
  5.   MsgBox "User Name required.", vbExclamation
  6.   txtuser.SetFocus
  7.   Exit Sub
  8. End If
  9.  
  10. ' Check for null password
  11. If txtpass = "" Then
  12.   MsgBox "Password required.", vbExclamation
  13.   txtpass.SetFocus
  14.   Exit Sub
  15. End If
  16.  
  17. Set conn = New ADODB.Connection
  18. conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & app.Path & "\password.mdb;Persist Security Info=False"
  19.  
  20. Set rs = New ADODB.Recordset
  21. msql = ""
  22. msql = "Select * From pass " & _
  23. "where password like '" & txtpass.Text & "%'"
  24. Set rs = conn.Execute(msql, , adCmdText)
  25.  
  26. If rs.RecordCount <> 0 Then
  27.   msql = UCase(Trim(rs("username")))
  28. End If
  29.  
  30. rs.Close
  31. Set rs = Nothing
  32.  
  33. If msql <> UCase(Trim(txtuser)) Then
  34.   MsgBox "Incorrect password", vbExclamation
  35. Else
  36.   MsgBox "Right Password!", vbExclamation
  37.   Unload frmLogin
  38.   frmSplash.Show
  39.   ' Load (but don't show) the project's main form.
  40.   Load frmGSOMain
  41.   Do
  42.     DoEvents
  43.   Loop Until frmSplash.ReadyToClose
  44.  
  45.   ' Show the project's main form & get rid of the splash screen.
  46.   frmGSOMain.Show
  47.   Unload frmSplash
  48.   Set frmSplash = Nothing
  49.   txtpass = Empty
  50. End If
  51. End Sub
Can you tell us at what point in this code the error is reported?

Personally I'm suspicious of the line I highlighted, for a couple of reasons...
  • I'm only really familiar with plain MS Access, and I believe it would expect * rather than %. This may or may not be the case here.
  • Why are you looking for a wildcard value in the password? Isn't that a fairly big security hole? I could just enter A and have maybe 1 chance in 26 of matching anyone's password. Or am I misreading this part? Anyway, I probably wouldn't recommend using Like to match the password. Others may feel differently.
Also, where you said "long password" were you actually referring to the length of the password, or was that "wrong password" mis-typed. It's hard to tell from the context, but might make a big difference in debugging.
Jan 4 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.