Well, you have read on how to create a module for database connectivity in Visual basic in my previous blog. Now, we are going to use the module in your created log-in form.
Let’s code. Let us first perform the function of logging in:
Suppose we have created two accounts in your table LoginTable:
e.g.
username Password
Wally password
Casuga pwd
Back to your design, double click the Log-in button and write the following codes:
Dim rs as recordset ‘this is just to set where you will store your record
Set rs = gsql(“SELECT * FROM LoginTable WHERE username = ‘” & txtUsername & ”’ and password = ‘” & txtpassword & ”’”
‘this is the query for retrieving username and password in the ms access dbase
If rs.recordcount <> 0 then
Msgbox “Access Granted”
Else
Msgbox “Access Denied”
End if
So Easy right? Once you have configured the module rightly, you can manipulate your database in a very easy manner. If not. Please review again how to connect your database in visual basic.
No comments:
Post a Comment