Displaying an Oracle 10G XE Table with Visual Basic 6.0 - Connect the ADO Data Control to the table to be displayed
(Page 4 of 4 )
Click on the authentication tab. It should come up with the one you configured earlier. In case it does not come up with the credentials, you must use the User Name/Password to proceed to the next tab. Click on the tab RecordSource.

It comes up with the default, adCmdUnkown. Since we will be displaying the contents of a table, choose adCmdTable from this drop-down list. Click on the OK button.

This should now reveal the Table or Stored Procedure Name combo box. When you click on the drop-down, you should see all the tables in Oracle 10G XE's HR database as shown. Click on the table Employees to choose it and then click OK.

Displaying the table using data bound controls
In this section the ADODC Data Control will serve as the source of data for the data bound controls, and we will see how it is done. You may use any of the data bound controls such as Textbox, Listbox, or Combobox and bind them to data using this control. In this tutorial, to keep it simple, only the Textbox control will be used. Place four textboxes and four labels as shown on the form. Each of these text boxes will be bound to a column in the Employees table. For example, the next couple of pictures show how you may bind the Employee_ID column on Oracle to Textbox1. Although labels in VB6 can also be bound to data, resist doing so for this tutorial.

Right click Textbox1 to bring up its Properties window as shown. You may click on the Categorized tab so that you can concentrate on data-related items. When you click on the empty space alongside the DataSource you should be able to pick up Adodc1. You could have a number of ADO Data controls on a form and all of them will show up in the drop-down list. Next, click on an empty area alongside the DataField item (shown in red, "click here"). In the empty area you will see a drop-down list from which you now choose Employee_ID. By this choice you have bound Textbox1 to the EmployeeID Column. Even at this point you may run the project and see only the Employee_ID.

Similarly configure the other textboxes. In this tutorial the third textbox has been bound to the telephone number field in Oracle 10G XE. You may also format this to show the telephone number. For this you need to click on an empty area of the DataFormat item in the bound controls Properties window. This brings up this next window where you may supply formatting to be displayed. An example for the column Telephone is shown. This custom formatting does not seem to be working, as the format string does not conform with the one configured. The way it is showing up is exactly the same as you would see in the Oracle database table.

Now you may run the project to display some of the columns in Oracle 10G XE's Employee table in the HR database. You may click on the navigational keys to move to the first, last, next and previous positions.

Summary
Connecting to an Oracle 10G XE database table using Microsoft's ADODC control was described in this tutorial. Once you get past the successful testing of the ODBC connection the rest of it is very easy. Although an example of binding to the textbox is shown, it is relatively easy to connect to other databound standard controls as well as the DataList (Microsoft DataList Control 6.0, MSDATALIST.ocx) and DataGrid (Microsoft DataGrid Control 6.0, MSDATAGRID.ocx) controls. In this case you may have to add these ActiveX controls to your toolbox.
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |