Hi guys, Im seeking help here. Been trying but yet i cant figure out what is wrong with my code here.
Imports System.data.OleDb
Public Class Login
Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click
Dim connStr As String = _
"Provider=Microsoft.Jet.OleDB.4.0;Data Source=LoanReturn.mdb"
Dim conn As New OleDbConnection(connStr)
Dim comm As New OleDbCommand("Select StaffID,Password from Staff where StaffID = " & tbxUsername.Text & " " & _
" and password = " & tbxPassword.Text & " ", conn)
conn.Open()
Dim da As New OleDbDataAdapter(comm)
Dim ds As New DataSet()
da.Fill(ds, "StaffID", "Staff")
Dim reader As OleDbDataReader = comm.ExecuteReader
If Not reader.Read() Then
MessageBox.Show("Please enter your username & password again.", "Incorrect Username or Password", MessageBoxButtons.RetryCancel, _
MessageBoxIcon.Exclamation)
Else
Dim f As New LoanReturn
Me.Hide()
f.Show()
End If
conn.Close()
End Sub
I have a access database that includes the StaffID and Password. My idea is to get this login form works with the database, meaning the StaffID and Password the user enters should be the same as in the database. When the StaffID and Password are entered correctly, it will get to another form.
I really appreciate if someone able to give me a helping hand. Im a newbie and still doing my best to master this
vb 2005.