Introduction
Using ATK ActiveX server, you can display tabular views from an ObjectStore database without coding a complex application. ATK provides an object model that you can use with any ActiveX-compliant development tool, such as Visual Basic. Using the classes and methods in the object model, you can easily inspect the database from the development environment that best meets your needs. Software requirements
To complete the exercises in this chapter, you need these software resources:
Resource | Where to Find It |
Database | \odi\ATK6.0\Examples\demodbs\carsdemo.db |
Visual Basic projects | \odi\ATK6.0\Examples\Tutorial1 |
In this chapter
In this chapter, you create a Visual Basic application that uses the ATK ActiveX server to retrieve tabular information from an ObjectStore database. This chapter contains these exercises:
Fill a List Box with Data
Overview
The simple Visual Basic application you construct in this chapter opens the ObjectStore carsdemo.db database. It uses a list box to display the contents of a data view you define using ObjectStore Inspector. Process
To fill a list box with data, follow these steps: Building the Application
1 Create a new data view to display in the Visual Basic application.
2 Customize the instance format.
The instance format is a way to specify which data members are available to the application. You can save an instance format explicitly, as part of a grid template, or implicitly, as part of the data view.
The left pane of the Instance Format sheet lists all data members in the data view; the right pane shows the members that have been included in this instance format.
3 Save the instance format as a grid template.
As mentioned earlier, you can save instance format information explicitly, with a grid template, or implicitly, as part of the data view. Instance format information saved with a grid template can be used by ATK - in fact, you can have ATK select any instance format associated with a data view when the instance format is saved with a grid template.
4 Save the new data view.
5 Create the Visual Basic ATK ActiveX Client.
Now that you have created an instance format, create a Visual Basic ATK ActiveX client to display the data. Build a form with a list box that displays the items from my_tut1_table1 and a button to load and refresh the data in the list box.
6 Reference the ATK type library.
7 Write Visual Basic code to access the ATK ActiveX server.
Dim anATKKernel As New ATKKernel
Dim anATKDatabase As ATKDatabase
The variable anATKKernel is also instantiated to an ATKKernel object.
Tip: Because you referenced the ATK type library in your Visual Basic project, these ATK data types are available in the drop-down list box:
8 Test the application.
9 Order the data by work order number.
Modify the index path in the my_tut1_table1 data view. An index path is an ordered set of data members that users can navigate. Specify an index path that provides navigation from the WorkOrder to the WorkOrder::orderNumber data member.
10 Save the new data view.
11 Use the new data view.
To make the Visual Basic application open the new my_tut1_table2 data view, modify the command that retrieves the data view by changing the Set anATKDataview command. The change requires you to substitute my_tut_table2 for the previous entry, mytut1_table1. ...
Set anATKDataView = anATKDatabase.GetDataView("my_tut1_
table2")
...
12 Test the application.
Sample Code
The Visual Basic code for this example is available in \odi\ATK6.0\Examples\Tutorial1\tut1_1.frm. Fill a Grid Control with Data View Content
Overview
This simple Visual Basic application displays the contents of a data view in a grid control. Process
To fill a grid control with data view content, follow these steps: 1 Insert a grid control.
Visual Basic 5.x contains a MSFlexGrid grid control that displays and operates on tabular data.
2 Customize the grid control.
3 Change the code that loads the form.
Grid1.FixedCols = 0
Grid1.Cols = 5
The value 5 is a reasonable default for the number of columns in the grid. The code now looks like this:
4 Modify the code that handles the button click.
5 Test the application.
Next, you created a Visual Basic application to open the ObjectStore database, query the data view you created, and display the returned data in a list box on a form.
Then, you replaced the list box with a grid control, modified the Visual Basic code to display the data in that grid control, and implemented a Reload button to refresh the data.
Although this chapter focuses on using ATK with Visual Basic, these examples are also portable to other development environments that support ActiveX, such as Microsoft J++ or Borland Delphi.
Updated: 05/11/99 11:49:31