anyone can help me? my login doesnt work smoothly.
i want to login based on Username, Password & Category. So that, if the user is Admin all data can be access, while if user is Staff, only few data can be access.
Public Sub DoLogin()
Dim strsql As String
Dim con As New OleDbConnection(My.Settings.KK3DB)
strsql = "SELECT * FROM Staff WHERE [Staff_Id] = '" & txtUser.Text & "' AND [Staff_Username] = '" & _
txtPass.Text & "' AND [Staff_Position] = '" & cmbCat.Text & "'"
Dim cmd As OleDbCommand = New OleDbCommand(strsql, con)
con.Open()
Dim sdr As OleDbDataReader = cmd.ExecuteReader()
' If the record can be queried, it means passing verification, then open another form.
If (sdr.Read() = True) Then
MessageBox.Show("The user is valid! Welcome to KK3 Students Mailing System.", "Valid User", MessageBoxButtons.OK, MessageBoxIcon.Asterisk)
Form1.Label6.Text = txtUser.Text
Form1.Label15.Text = txtPass.Text
Form1.Show()
Me.Hide()
ElseIf (sdr.Read() = True) And cmbCat.Text = "STAFF" Then
Form1.Show()
Me.Hide()
Form1.Label6.Text = txtUser.Text
Form1.linkView.Visible = False
Else
MessageBox.Show("Invalid Username or Password.", "Login", MessageBoxButtons.OK, MessageBoxIcon.Error)
text_field()
End If
End Sub