- First, create a database and give the name of the database with the name login.mdb (author create a database using the Visual Data Manager in the Visual Basic 6.0)
- Then create a table and table name with the name info_login.
- On the table Info_login, add fields username and password fields. Data type for each of the Text, and for the field size is 50. Field username is the primary key.
- Give the value of each field:
- Field username : Admin
- Field password : Admin
After the database is ready, create a login form as below:

To Text2, sign on * PasswordChar properties.
- Click the Project menu
- And then References
- Then, marked on the Microsoft ActiveX Data Objects 2.7 Library.

- Then click Ok.
Once you add the component library, enter the code under this way:
- Click View menu
- Then click Code
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim try As Long
Private Sub Command1_Click()
On Error GoTo Error
try = try + 1
Set cn = New ADODB.Connection
Set rs = New ADODB.Recordset
With cn
.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\login.mdb" & ";Persist Security Info=False"
.Open
End With
If try <= 3 Then
With rs
.Open "SELECT * FROM info_login WHERE username ='" & Text1.Text & "' AND password='" & Text2.Text & "';", cn, adOpenKeyset, adLockOptimistic
If .RecordCount <= 0 Then
MsgBox "Invalid username or password!"
Else
MsgBox "Login success"
End If
End With
Else
MsgBox "Please contact your administrator if you lost information login!"
Unload Me
End If
Error:
If Err.Number = 0 Then Exit Sub
MsgBox Err.Description, vbOKOnly, "Error " & Err.Number
Err.Clear
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Load()
try = 0
End Sub
Function of As Long Dim try is to sign given the opportunity. Sign that the opportunity is given the opportunity 3 (you can change with the opportunity to change the value on the value I try <= 3 Then)




