My access table (Staff) has attributes StaffID, StaffName, Password, Role. StaffID is the primary key.
In my GUI, I have a combo drop down list which display the list of user. The display should be the staffName, not staffID.
I am trying to write codes if password entered by user in the GUI match with the record of StaffID in the access database, then do something. But I don't know how to write this.
At form load, I already have these.
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim conn As New OleDbConnection(connString)
Try
Dim comm_Staff As New OleDbCommand("Select StaffID,StaffName from Staff", conn)
conn.Open()
Dim da_staff As New OleDbDataAdapter(comm_Staff)
Dim ds As New DataSet
da_staff.Fill(ds, "Staff")
cbxStaff.DataSource = ds.Tables("Staff")
cbxStaff.DisplayMember = "StaffName"
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Private Sub btnLogIn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogIn.Click
Dim conn As New OleDbConnection(connString)
Try
'if tbxPassword.text = password of the selected StaffID
' but how to do this?
Form2.Show()
'else
'MsgBox("Wrong password")
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Please help. I am really lost.