getting the data from the database
I want to create a banking management system using vb.net. I have already created all the forms in vb.net. The main form is the login form, where the customer has to enter his or her username and password. If the username and password entered are correct, then the customer will be able to log in. Else, an error message will pop up.
These usernames and password details are stored in the Microsoft Access Database in a table named customer detail.
I am stuck in the part where i have to write the code to get these usernames and passwords from the customer detail table.
I have already done the connection,the data adapter and data set parts to connect and get information from the customer details table.
Re: getting the data from the database
ok so now you have the dataset try this:
Dim i As Integer
For i = 0 To DS.Tables("Users").Rows.Count - 1
If Trim(txtLogIn.Text) = DS.Tables("Users").Rows(i)("Name") AndAlso Trim(txtPassword.Text) = DS.Tables("Users").Rows(i)("Password") Then
End If
Next
If i = DS.Tables("Users").Rows.Count Then
MessageBox.Show("User or password incorrect,please try again!", MyCaption, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
End If
Re: getting the data from the database
It is not a good idea to get all the data regarding UserNames and passwords from the database. Rathjer you can check using a simple query whether the Username amd password entered by the user are correct or not.
Something like this
Code:
Select count(*) From USERTABLE Where USERNAME = 'enteredusername' And Password = 'enteredpassword'
If this query returns 0 then the username and password are invalid.