I have created a table in my access and i have inserted values in it. I also created a login page on my vb.net form in which i want a matcching field in the table to serve as my UserId and Password to allow user access the next form. I guess there is something i am missing out in my code. I would be glad if anyone can help me with useful hints..Also i wanna check if the fields selected match the database table record.
Below is my code
Try
Dim sqlquery As String = "SELECT MatricNo,FirstName FROM matt WHERE MatricNo = '" & txtUsername.Text & "' AND FirstName = '" & txtPassword.Text & "'"
Dim query As New OleDbCommand(sqlquery, hoc)
hoc.Open()
Dim reader As OleDbDataReader = query.ExecuteReader()
'reader = query.ExecuteReader()
While reader.Read()
txtUsername.Text = reader(0)
txtPassword.Text = reader(1)
End While
reader.Close()
hoc.Close()
'If txtUsername.Text = "" Or txtPassword.Text = "" Then
'MsgBox("Enter UserName and Password!")
'Else
Form4.Show()
'End If
Catch ex As OleDbException
MsgBox("ERROR!!")
End Try