Oke, now we try to make a login form.
but, we use database to store user name and password...
i use ms access 2003 to build the database.
in this application, there are 2 form. 1 for login and other for display the data.
here, the code...
#1) login form
Private Sub Command1_Click()
Adodc1.RecordSource = "select * from data_user where user_name='" & Text1.Text & "'"
Adodc1.Refresh
If Adodc1.Recordset.RecordCount > 0 Then
Adodc1.RecordSource = "select * from data_user where user_name='" & Text1.Text & "' and kode_password='" & Text2.Text & "'"
Adodc1.Refresh
If Adodc1.Recordset.RecordCount > 0 Then
'benar
Unload Me
Load Form2
Form2.Show
Else
MsgBox "Password salah!", vbInformation, "salah"
Text2.Text = ""
Text2.SetFocus
End If
Else
MsgBox "user name salah!", vbInformation, "salah"
Text1.Text = ""
Text2.Text = ""
Text1.SetFocus
End If
End Sub
Private Sub Command2_Click()
End
End Sub
Private Sub Form_Load()
sumber = App.Path & "\login.mdb"
Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & sumber & ";Persist Security Info=False"
Adodc1.RecordSource = "select * from data_user"
Adodc1.Refresh
End Sub
#2) data form
Private Sub Command1_Click()
End
End Sub
Private Sub Form_Load()
sumber = App.Path & "\login.mdb"
Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & sumber & ";Persist Security Info=False"
Adodc1.RecordSource = "select * from data_user"
Adodc1.Refresh
Set DataGrid1.DataSource = Adodc1
End Sub
.....
click here to download...
Friday, November 9, 2007
Login with database
Diposting oleh adi_vb di 1:24 AM
Label: login with database
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment