Login form using VisualBasic.NET, ADO.NET and MS Access
Posted on 2004-09-08
Hi, i am new to programming..
Here is what I am trying to do: I will have like 4 forms, each forms can by access by different type of user assigned in access table when login..
user password type name Address
john doe 1 John at home
Login Form: will have txtUser and txtPassword, how will I check user's input username and password against the table?
Once the user login, how do I pull all the information just on that ONE user that just logged in, example, his type, name and his addresss to be loaded into a different form. Aso, if user is type 1 , then load form Type1 for that user.. Basically I am not sure how to pull the exact field from the database to assigned it to a variable.
Here's what I have for Login form but. it keep showing "Valid" message box if i enter the correct username and password then "Invalid" msg box as if it keep checking for the next user name and password. How do I end the loop once it finds the matching user and password?
Dim password As String
Dim user As String
Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click
Dim tempUser As String
Dim dv As DataView
dv = DsEmployees.Tables(0).DefaultView
empID = txtUser.Text
password = txtPassword.Text
' Loop through table and compare each record against user's entry
For Each datarow As DataRowView In dv
' Extract user id from the current row
tempEmpID = datarow.Item("empid").ToString()
tempPassword = datarow.Item("password").ToString()
' Compare user id against user's entry
If (tempEmpID = empID) And (tempPassword = password) Then
Thank you guys and gals!!!