|
-
May 24th, 2012, 06:22 PM
#1
Problem validating multiple user
I am currently working on a project for school in which I am trying to implement a multi user login on one of my forms. I have an internal database connected in which one of my tables contains the user-names and passwords. I have a For/each loop to search the table for a matching username/password before allowing access to next form. The problem is even if the username/password is correct, my message box still appears to notify of invalid credentials, but still allows access to other form. The problem only occurs when I implement two For/each loops. With one, code works fine. Can any one see what might be wrong? Thanks
Code:
Dim h As New AdminActionForm
Dim i As New UserActionForm
For Each row As EmployeeDBDataSet1.UserName_PasswordsRow In EmployeeDBDataSet1.UserName_Passwords
If row.Password = txtLoginPassword.Text And row.UserName = txtLoginUserName.Text _
And row.Administrator = True Then
Me.Hide()
h.Show()
Exit For
ElseIf row.Password <> txtLoginPassword.Text Or row.UserName <> txtUserName.Text Then
MessageBox.Show("Invalid UserName or Password", "Incorrect Information", _
MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
Exit For
End If
'End If
Next
For Each row As EmployeeDBDataSet1.UserName_PasswordsRow In EmployeeDBDataSet1.UserName_Passwords
If row.Password = txtLoginPassword.Text And row.UserName = txtLoginUserName.Text _
And row.Administrator = False Then
Me.Hide()
h.Show()
Exit For
ElseIf row.Password <> txtLoginPassword.Text Or row.UserName <> txtUserName.Text Then
MessageBox.Show("Invalid UserName or Password", "Incorrect Information", _
MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
Exit For
End If
'End If
Next]
Last edited by GremlinSA; May 25th, 2012 at 01:57 AM.
Reason: fixed formating
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|