A Simple Database 

 

You can program a fairly good database management system using Visual Basic.  It allows us to manage databases created with different database programs such as MS Access, Dbase, Paradox and etc. In this Lesson, I will use MS Access to create a table call Library.mdb. In this database, you shall create six fields, namely ISBN, Title, Author, Publisher, Year and Category. After you have created the database, you can enter some data from the MS Access table.

Now, you shall create the interface.  To create the interface, insert the labels and name them accordingly. Then, insert six corresponding text boxes and name them as Txt_ISBN, Txt_Title, Txt_Author, Txt_Publisher, Txt_Year and Txt_Category respectively. Next, you have to insert the ADO control into the form. ADO stands for ActiveX data object. As ADO is ActiveX-based, it can work in different platforms (different computer systems) and different programming languages. Moreover, it can access many different kinds of data such as data displayed in the Internet browsers, email text and even graphics other than the usual relational and non-relational database information. ADO data control is not normally shown in the toolbox, you need to  press Ctrl+T to open the components dialog box and then select Microsoft ActiveX Data Control 6. After this,the ADO control will appear in the toolbox. Place the data control somewhere at the bottom of the form. Name the data control as library. To be able to use the data control, you need to connect it to Library.mdb. The Interface is shown below:

To be able to access and manage a database, you need to connect the ADO data control to the database file, follow the steps below:

a) Click on the ADO control on the form and open up the properties window.

b) Click on the ConnectionString property, the following dialog box will appear.

c) When the dialog box appears, select Use Connection String. Next, click build and at the Data Link dialog box, double-click the option labeled Microsoft Jet 4.0  OLE DB provider.

 

After that, click the Next button to select the file Library.mdb. You can click on the Text Connection to ensure proper connection of the database file. Click OK to finish the connection. Finally, click on the RecordSource property and set the command type to adCmd Table and Table name to Titles. Now you can really use the database file.

 

 

 

 

 

 

 [Back to VBToday]