Private Sub cmdOK_Click()
Adodc1.Recordset.MoveFirst
Do While Not Adodc1.Recordset.EOF
If Adodc1.Recordset.Fields(0) <> txtuser.Text Or Adodc1.Recordset.Fields(1) <> txtPassword.Text Then
MsgBox "Please verify login details", vbInformation + vbOKOnly, "Login Denied"
txtuser.SetFocus
txtuser.Text = ""
txtPassword.Text = ""
Else
Unload Me
Load Main
Main.Show
End If
Adodc1.Recordset.MoveNext
Loop
End Sub
I would appreciate it if someone looked at the code snippet above and told me if any changes need be made? This is the code I use for a login form that connects to a SQL SERVER 2005 DB, Now why isn't this working? It seems to ONLY fetch the data from the first row of the two columns, not the rows that follow?
I would take a step back and rewrite all of this. You should be sending the database the username and password, not sending every username and password to your application and looping through it. Let the DBMS do the work for you. I would also suggest that you refrain from storing passwords as plain text (as it appears you are doing). This information is general and can be found by searching, but if you're having a particular problem, post back.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.