Using Visual Basic ADODC to connect with MS Access Database (.mdb)

The ADODC or Active Data Objects Data Control is a method added in Visual Basic 6.0. It allows a programmer to put controls, such as labels, text boxes, list boxes and other display controls, on a form and connect them to the Data Control, which then connects to a database. This provides considerably more power to the developer in creating and maintaining databases.

Connecting Adodc from your MS Access database is quite complicated, but if you'll going to follow this steps carefully, it's very easy... ツ

1st. Right click your ADODC object and click ADODC Properties.


2nd. Property Pages Window will appear. Click the Build button.


3rd. Data Link Properties Window will appear. Choose Microsoft Jet 4.0 OLE DB Provider.
(This provider is used if your database is from Microsoft Access .mdb file.)
...and click Next button.
NOTE: Your database must be save as .mdb file format.
If you are using MS Access 2007 or higher, just Save As your database in MS Access 2003
for it to become .mdb file.
.accdb is the file name extension of 2007 which is not compatible with Visual Basic 6 ADODC.


4th. Browse your MS Access database from your computer.
In the sample, the address of the database is
D:\Files\VB6\myDatabase.mdb.
The file name of the database is myDatabase.mdb.

TIP:You can erase D:\Files\VB6\ in the text field so that you have no problem if you'll going to transfer your Application or your database to another area/computer. (It is very helpful, i swear! ツ)


5th. Click Test Connection Button. Test connection succeeded must appear and click OK button.
If error message appear, just try again browsing your database file.



6th. In the Property Pages Window, Click the RecordSource Tab.
In Command Type, choose 2 - adCmdTable.
Then in Table or Stored Procedure Name, choose the table you'll going to use.
The sample table name in the image is Customers.
Click Apply and OK button simultaneously.


...and that's it!... your MS Access database is now connected to your Visual Basic Application using ADODC... ツ

If you have questions or clarifications, don't hesitate to post a comment below... ツ

Blog Archive