Create a simple database program that can add a record using Visual Basic 6.0 and Microsoft Office Access.. :) Enjoy.. Full-screen the vid for the best result..
1. Open MS Access.
2. Create blank database, "try".
3. Create Table1.
4. Delete Id Field, then add two fields, "username" and "pass", in
text format.
5. Set database password, "admin" then close the MS access.
6. Open VB6, open Standard Exe.
7. Add a component, MS Datagrid Control and MS ADO Data Control.
8. In the form, add 2 labels, 2 texts, 1 command button, 1 adodc
and 1 datagrid.
9. right click the adodc1, then click the adodc properties, on GENERAL
tab, selectuse connection string then build; select Jet 4.0 Ole DB
Provider then click next; browse the database that you've created
earlier; then on the ALL tab set the database password to "admin";
test the connection; if success then click ok..
10. Copy the connection string then click cancel.
11. Put all the codes.. :) Paste the connection string that you've
copied..
12. Run, debug and test.. :)
13. Finish!
Private Sub Form_Load()
On Error Resume Next
Adodc1.ConnectionString = “CONNECTION STRING”
Adodc1.RecordSource = “select * from table1″
Set DataGrid1.DataSource = Adodc1
End Sub
Private Sub Command1_Click()
On Error Resume Next
Adodc1.Recordset.MoveFirst
Adodc1.Recordset.Find “username like ‘” & Text1.Text & “‘”
If Text1.Text = “” Or Text2.Text = “” Then
MsgBox “You must enter an id and a password!”, vbCritical + vbOKOnly, “Attention!”
Else
If Adodc1.Recordset.EOF = True Then
Adodc1.Recordset.AddNew
Adodc1.Recordset!UserName = Text1.Text
Adodc1.Recordset!pass = Text2.Text
Adodc1.Recordset.Update
Else
MsgBox “Id Already Taken!”, vbCritical + vbOKOnly, “Add Record”
End If
End If
End Sub
-- is0ng..
aush kuya isong!
ReplyDeletevery useful..
magagamit kuh yan.. soon.. xD
tnx for sharing..
bkt? magI-IT or ComSci kba?
ReplyDeletewla un.. :)
lalagay pa ko d2.. =))