The next step in creating the datasource is to actually construct a database in Microsoft Access. You can build the database either by using Microsoft Access directly or by using the Data Manager included with Visual Basic. For this project, you will create the database by using the Data Manager. If you prefer to create the database in Access, you may do so and then turn to the exercise in the "Defining the Datasource" section on page 201. In any case, you will create a database with the structure shown in Table 6-1.
Table 6-1.The People Table
Field Name | Data Type |
Name | Text |
Department | Text |
Text |
Start Visual Basic 4.0. Open the Data Manager by selecting Add-Ins/Data Manager from the Visual Basic menu bar. The Data Manager will start, and you will see a form with File and Help menus.
Create a new database by selecting File/New Database from the Data Manager menu bar. After the New Database dialog box appears, navigate to the folder \bookdata\project1, type in the file name subscrib.mdb, and then click on the OK (or Save) button. Figure 6-6 shows the resulting Data Manager window that is displayed.
Figure 6-6.
The subscribers database created with the Data Manager.
Add a new table to the database by clicking on the New button. The Add Table dialog box should appear. Name the new table People.
Add the fields from Table 6-1 to the database one at a time by filling in the Field Name text box with the appropriate name. For each field, select Text from the Data Type combo box and set the field size to 250. Click on the right arrow button to add each field. The fields will appear in the list box in the center of the dialog box. Figure 6-7, on page 200, shows the completed People table in the Add Table dialog box.
Figure 6-7.
The Add Table dialog box showing the completed People table.
Click on the OK button in the Add Table dialog box. The People table should appear in the Data Manager. Figure 6-8 shows the subscribers database with the People table added. Minimize the Data Manager so that you can access the database directly anytime during the exercise. When you are working with ODBC drivers, direct access via the Data Manager can be helpful for troubleshooting.
Figure 6-8.
The subscribers database with the People table added.