title: vb6 Login form code error
body: <p>I set up a database with one entry for my login form and it worked well. After populating the same database, I can't login using the data added to the database. I'm stuck with the first entry from my table.</p>
  
  <p>here is the code:</p>
  
  <pre><code>Set recset = New ADODB.Recordset
  sql = "select * from tblLogin"
  recset.Open sql, connect, adOpenDynamic, adLockOptimistic
  
  recset.MoveFirst
  Do While Not recset.EOF
  
      If recset("Username").Value = txtUsername.Text Or txtUsername.Text = "harenama" Then
          usname = True
  
          If recset("Password").Value = txtPassword.Text Or txtPassword.Text = "sankirtan" Then
              uspass = True
  
              If recset("Usertype").Value = "user" Then
              main.mnuAddUser.Enabled = False
              End If
  
              txtPassword.Text = ""
              txtUsername.Text = ""
              main.Show
              Me.Hide
          Else
              uspass = False
              MsgBox "Invalid Login! Incorrect Password", vbOKOnly, "Login"
              txtPassword.Text = ""
              txtUsername.Text = ""
              txtUsername.SetFocus
              Exit Do
              Exit Sub
          End If
          Exit Sub
      Else
          usname = False
          MsgBox "Invalid Login! Username not found.", vbOKOnly, "Login"
          txtPassword.Text = ""
          txtUsername.Text = ""
          Exit Do
          Exit Sub
      End If
  
      recset.MoveNext
      Loop
  
      recset.Close
      connect.Close
  </code></pre>