DataBinding approach and MS Access to access the data from your database source.
This is the user login. Your be able to login if you have already an account stored in database or you may create a new one, but the username check if it is already exists or not. The program does not automatically store your new account unless you could not create a new one.
Public Class UserLoginPrivate Sub btnlogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnlogin.ClickDim login = TbluseraccountTableAdapter1.ScalarQueryLogin(txtusername.Text, txtpassword.Text)If login Is Nothing ThenMessageBox.Show("Invalid Username or Password")ElseMsgBox("Welcome")End IfEnd SubPrivate Sub linkcreateaccount_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles linkcreateaccount.LinkClickedAdd_new_account.ShowDialog()End SubEnd Class
Create new account for the user:
Create Username and Password. Make sure that the password is match to another textbox which is confirming password.
Public Class Add_new_accountPrivate Sub btnsubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.ClickDim checkuser = TbluseraccountTableAdapter1.ScalarQuerycheck(txtusername.Text)If checkuser Is Nothing ThenIf txtpasswordconfirm.Text = txtpassword.Text ThenTbluseraccountTableAdapter1.InsertQueryUser(txtusername.Text, txtpassword.Text)MessageBox.Show("New user added to your database")ElseMessageBox.Show("Password not match")End IfElseMessageBox.Show("Username is already exists")End IfEnd SubEnd Class
Here is the quick and simple Video Tutorial how to Login in VB.NET.
This is the DataSet where you can query using the TableAdapter
Here are the following Query:
Fill, GetData() 'it's already given
SELECT ID, Username, [Password] FROM tbluseraccount
InsertQueryUser (Username,Password)
INSERT INTO tbluseraccount
(Username, [Password])
VALUES (?,?)
ScalarQuerycheck(Username)
SELECT COUNT(*) AS Expr1, Username AS UsernameResult
FROM tbluseraccount
GROUP BY Username
HAVING (Username = ?)
ScalarQueryLogin (Username,Password)
SELECT COUNT(*) AS Expr1, Username AS UsernameResult, [Password] AS PasswordResult
FROM tbluseraccount
GROUP BY Username, [Password]
HAVING (Username = ?) AND ([Password] = ?)
keep it up..:)
ReplyDeletecode for update and delete pls using tableadapter tnx
ReplyDeleteCan i please buy this?
ReplyDeletewhat do you mean?
ReplyDelete