How to add 3rd validation for form login with UsernamePasswordString code?

Hello,

I have below code for form login using validation from access database. In database I have now three columns, for user, for password, and new one for department.

Can someone show me how can I add also a deparment for login validation?

Maybe to adda combobox under password and userid, and that user will have to enter ID, Password, and choose from combobox a department to which belong.

 If UserIDTextBox.Text = "" Then
            ErrorProvider1.SetError(UserIDTextBox, "No UserID")
            Me.ActiveControl = UserIDTextBox
        Else
            If PasswordTextBox.Text = "" Then
                ErrorProvider2.SetError(PasswordTextBox, "No password")
                Me.ActiveControl = PasswordTextBox
            Else

                Dim login = Me.LoginIDTableAdapter1.UsernamePasswordString(UserIDTextBox.Text, PasswordTextBox.Text)
                If login Is Nothing Then
                    MsgBox("Error login.", MsgBoxStyle.Critical + vbOKOnly, "Error login")
                Else
                    MsgBox("Successfull login. " + UserIDTextBox.Text.ToUpper, MsgBoxStyle.Information + vbOKOnly, "Successfull login")
                    Form1.Show()
                    Me.Hide()
                End If
            End If
        End If

Open in new window


Thank you in advance for help.
dejandejanovicAsked:
Who is Participating?
 
Praveen KumarArchitectCommented:
Goto method UsernamePasswordString in LoginIDTableAdapter1 class, add new parameter to and change SQL statement & validation logic accordingly.
0
 
dejandejanovicAuthor Commented:
Uf, that is a explination for experts :-)

As, I'm a begginer, can you please show on example.

Thank you, and thx for reply.
0
 
dejandejanovicAuthor Commented:
I have found. I have add a Department column in Sql statement, and also in Vb code.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.