need help

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mabzkie
    New Member
    • Jan 2007
    • 19

    need help

    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
  • mabzkie
    New Member
    • Jan 2007
    • 19

    #2
    --------------------------------------------------------------------------------

    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:
    Code:
    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

    Comment

    • Killer42
      Recognized Expert Expert
      • Oct 2006
      • 8429

      #3
      Originally posted by mabzkie
      Code:
      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 " & _
      [B][U]"where password like '" & txtpass.Text & "%'"[/U][/B]
      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
      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.

      Comment

      Working...