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.SetFocu s
Exit Sub
End If
'check for null password
If txtpass = "" Then
MsgBox "Password required.", vbExclamation
txtpass.SetFocu s
Exit Sub
End If
Set conn = New ADODB.Connectio n
conn.Open "Provider=Micro soft.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(ms ql, , adCmdText)
If rs.RecordCount <> 0 Then
msql = UCase(Trim(rs(" username")))
End If
rs.Close
Set rs = Nothing
If msql <> UCase(Trim(txtu ser)) 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.Ready ToClose
'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
This is my codes:
Private Sub cmdLogin_Click( )
'check for null password
If txtuser = "" Then
MsgBox "User Name required.", vbExclamation
txtuser.SetFocu s
Exit Sub
End If
'check for null password
If txtpass = "" Then
MsgBox "Password required.", vbExclamation
txtpass.SetFocu s
Exit Sub
End If
Set conn = New ADODB.Connectio n
conn.Open "Provider=Micro soft.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(ms ql, , adCmdText)
If rs.RecordCount <> 0 Then
msql = UCase(Trim(rs(" username")))
End If
rs.Close
Set rs = Nothing
If msql <> UCase(Trim(txtu ser)) 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.Ready ToClose
'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
Comment