Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

Creating a data base:

 Goto Addins,
 Select visual data manager
 Click on file and select new Microsoft Access Data base
 Select Microsoft Access version 6.0
 Give the name of the database.
 Create a table in the database
 Create a table.
 Give the name of the table and save.
 Add fields to the table by clicking on add and give the name of the field
and select the data type and range of data it can take
 Add second field and password and select the data type and range
 Enter the values to the fields
 Close the addin manager

Form Design
Controls:
3 labels
2 text boxes
3 command buttons
 Goto project menu, select components
 Add Microsoft adodb 6.0 sp oledb
 Use the control on the form
 Right click on adodc properties
 Use select connection string option,
 Select the name of the database and click on test connection option.
 Once the connection is succeded, select the record sourse,select the
command type as table and select the name of the table
 Goto connection string and copy the entire connection string and goto
form load event and rs. Open method paste the connection string .
 Enter the following code
 Save the form and project

Dim con As New ADODB.Connection


Dim rs As New ADODB.Recordset

Private Sub Command2_Click()


Text1 = ""
Text2 = ""
Text1.SetFocus
End Sub

Private Sub Command1_Click()


If Text1 = "" Then
MsgBox "enter user name"
Text1.SetFocus
Exit Sub
End If
If Text2 = "" Then
MsgBox "enter password"
Text2.SetFocus
Exit Sub
End If
If Text1 <> "" And Text2 <> "" Then
rs.Open "select * from login where username='" & Text1 & "' and password='"
& Text2 & "'", con, adOpenDynamic, adLockOptimistic
If rs.EOF Then
MsgBox "invalid user name and password"
Text1 = ""
Text2 = ""
Text1.SetFocus
Else
MsgBox "valid username and password. login successful!!"
End If
End If
rs.Close
End Sub

Private Sub Command3_Click()


End
End Sub
Private Sub Form_Load()
con.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and
Settings\Administrator\Desktop\logindb.mdb;Persist Security Info=False"
End Sub

You might also like