Using the Oracle Data Control with MS VC++
This example shows how to create a simple Win32 Application with the Oracle Data Control using MS VC++. This example assumes that both the Oracle Data and DB Grid controls have been registered on the system.
- Start the Microsoft Visual C++ program.
- Select New from the File Menu.
- In the Projects Tab of the New Window select MFC AppWizard. Enter a project name, such as OO4O, and determine the location of the project. Select Create.
- In the first page of the MFC AppWizard, select dialog based application, then select Next.
- In page 2 of the wizard, make sure the ActiveX Controls box is checked, accept the default checks, and enter a title for the project.
- In page 3 of the wizard, accept the defaults.
- In page 4, select finish. Select OK at the New Project Information screen.
- In the Project Workspace dialog box, select the ResourceView tab. Expand the Resources folder, then expand the Dialog folder.
- Double-click on the main project dialog box to allow you to edit the dialog. Note: If you used OO4O as the project name, it would be named IDD_OO4O_DIALOG.
- Delete the default controls that are on the dialog. Resize the dialog to make it larger.
- With the dialog selected, press the right mouse button to display the pop-up menu. Select Properties from the menu. In the General tab of the Properties window, change the caption to Oracle Data Control Example. Close the properties window.
- With the dialog selected, press the right mouse button to display the pop-up menu. Select Insert ActiveX control from the menu. Select Oracle Data Control in the window and then select OK.
Text description of the illustration oradcins.gif
- Position the Oracle Data Control at the bottom of the dialog. With the data control selected, press the right mouse button to display the pop-up menu. Select properties from the menu.
- In the General tab of the Properties window, change the ID to IDC_ORADATACONTROL. Remove the check for Visible so the control is hidden when the application is run.
- Display the All tab of the Properties window and set the following:
·
Connect: scott/tiger
· Database: exampledb
· RecordSource: select * from emp
Text description of the illustration oradcprp.gif
16. With the dialog selected, press the right mouse button to display the pop-up menu. Select Insert ActiveX control from the menu. Locate the DB Grid Control and select OK.
17. Position the DB Grid Control at the top of the dialog and resize. Display the properties for the control. In the All tab of the Properties window, set the DataSource property to the Oracle Data Control (IDC_ORADATACONTROL). Accept the defaults for the other properties for now. These can be changed later.
18. Select Save All from the File Menu.
19. Build and Execute the project.
20. The DB Grid displays the records from the emp
table as in the following illustration.
Text description of the illustration oradcemp.gif