-- D --

Using Personal Oracle7 and Visual Basic

This appendix explains how to use Visual Basic with Personal Oracle7 for Windows 95. The example in this appendix uses Visual Basic Enterprise edition 4.0. As you probably know, Visual Basic is a very popular tool for developing Windows applications. Unlike the tools described in the other appendixes, Visual Basic is not intended for use only as a client/server development tool.

Among the strengths of Visual Basic are

Although Visual Basic is a popular tool, the example in this appendix illustrates that some of the features found in tools such as PowerBuilder and Oracle Power Objects are missing from Visual Basic. Visual Basic's shortcomings as a tool for building database applications include the following:

In this example a Visual Basic data control accesses the Repair_Header table. As you can see, even though no coding is required to access the table, Visual Basic cannot generate a default form from a table definition; PowerBuilder, Oracle Forms, and Oracle Power Objects are able to generate a default form. Figure D.1 shows the appearance of the Visual Basic environment when the program first starts.

Figure D.1.

The Visual Basic environment: the initial form. To add a data control to the form, select the data control icon from the VB toolbox (in the right column of icons, second from the bottom). Size the data control to your liking. To use an ODBC data source with the data control, set the Connect property to ODBC;DSN=Frayed Wires;UID=FRAYED_WIRES;PWD=HELMHOLTZ;.(See Figure D.2.) Set the Caption property to Repair_Header.

Figure D.2.

Adding a data control to the form. Scroll down the list of properties. Set the RecordSource to Repair_Header (see Figure D.3); the data control will be attached to this Personal Oracle table.

Figure D.3.

Modifying data control properties. Now add four text fields and four labels to the form. (See Figure D.4.) Each text field corresponds to a column in the Repair_Header table.

Figure D.4.

Adding text fields to the form. Set the caption of each label to correspond to its adjoining text field. (See Figure D.5.) After all the labels have been modified, you can set the properties of each text field. (See Figure D.6.)

Figure D.5.

Modifying the labels.

Figure D.6.

Setting the properties of the text fields. The DataSource property for the text fields should be set to the same data control: Data1. In this way, each text field is bound to the data control. You can set the DataSource by simply clicking the DataSource field on the Properties window. For each text field, set the DataField to the column that you want to display in the field. In Figure D.7 the DataField property for the Repair_ID text field is set to Repair_ID; the DataSource property is set to Data1.

Figure D.7.

Setting the DataField and DataSource properties for a text field. To run the form, select Run or press F5. To navigate through the records in the table, click the first, previous, next, or last control on the Repair_Header data control. (See Figure D.8.)

Figure D.8.

Running the form.