How to Use a Microsoft Data Access Object Comfortably in Vb 6.0
Edited by Fndungu83, Teresa, Carolyn Barratt, Gaurang and 2 others
Many people have tried to find a way to link their vb projects with databases but not many have succeed. One best way is to use the Microsoft data access object.
EditSteps
-
1Make your forms in vb 6.0 and make sure the display is attractive.Ad
-
2Design a database and make sure you put all necessary tables.
-
3Then from the forms you just created make sure you have the main form which will be used as the main user interface
-
4Select the form you want to connect to the database, lets say the form have three fields namely: name, country and telephone.
-
5Your form should also have a save button so that when you click at it then users will be able to save the information on the database.
-
6Make a list of the following.
- Your database name e.g people.mdb.
- Your table name e.g register.
-
7Then from your form double click the "saving button" on the form.
-
8Insert the following information on the coding space
- dim dbpeople as database
- dim dbregister as recordset
- set dbpeople=opendatabase("app.path & /People.mdb")
- set tblregister=dbpeople.openrecordset("register")
- tblregister.addnew
- tblregister!name=txtname.text
- tblregister!country=txtcountry.text
- tblregister!telephone=txttelephone.text
- tblregister.update
- msgbox "Your record was successfully saved."
-
9Then go to tools references and add a reference to Microsoft Data access object -locate it and move it to the first priority using the up arrow.
-
10Now run your form and enter the details.
-
11Click on save and the contents of the forms will be put on the database.
-
12Remember to put the database in the same folder you have saved your project.Ad
Article Info
Thanks to all authors for creating a page that has been read 2,491 times.