Use OLE Automation from Visual Basic to control the database object model.
In the first part of this two-part article, "Creating a Database Object Model," (August 1996), you saw how you could build an architecture that practically maintains itself. I used Visual C++ to build automation objects that can be called from any development environment that supports OLE Automation. The objects were created to support a hierarchy of components that could be used and reused indefinitely.
There are objects to open a database using open database connectivity (ODBC) as the underlying technology that allows you to talk to any database backend. Not only is the front end flexible enough to be used by any development environment or language, but because the back end uses ODBC, it's just as flexible. The other objects supported by the package include components that allow you to create what are called Recordsets (similar to cursors, since the data from a query is returned based on a SQL Select statement). These components support building a class information for what I call a Business Data Object, and of course, let's not forget the components that hold the data for the Business Data Objects.
Collectively, these components are known as a database object model. Together, the automation components provide a rich environment for your applications, and ease the process of building your applications, as well as the maintenance that must be reiteratively performed year after year on database aware applications.
Let's get a couple of terms defined before moving on. The term component server means the module that contains the component classes to be used from another application. The server basically services another application's request (just asa waiter provides services for clients in a restaurant). Controller means the application that uses the services of a component server to control it and has it perform tasks for the controller.
The term component refers to the automation objects exposed from the server using OLE's IDispatch interface. Visual Basic makes using this interface a cinch, since it hides most of the details of using the interface.
The basics of using the model
Last time out, I explained what had to be done from the component server side. This time, I start by, explaining the tasks that must be performed by the controller, and take a look at an example that uses Visual Basic to gain access of the components.
To refresh your memory, figure I shows the components …