Learn How To Log in The User by Checking The Username and Password Stored in An Access Database
Learn How To Log in The User by Checking The Username and Password Stored in An Access Database
database.
Now let's connect the program in Simple Login Tutorial to the database we created.
'the query:
Dim cmd As OleDbCommand = New OleDbCommand("SELECT * FROM [users] WHERE [username] = '" &
TextBox1.Text & "' AND [password] = '" & TextBox2.Text & "'", myConnection)
Dim dr As OleDbDataReader = cmd.ExecuteReader
' the following variable is hold true if user is found, and false if user is not found
Dim userFound As Boolean = False
' the following variables will hold the user first and last name if found.
Dim FirstName As String = ""
Dim LastName As String = ""
'if found:
While dr.Read
userFound = True
FirstName = dr("FirstName").ToString
LastName = dr("LastName").ToString
End While