|
This section describes how to set up DTO for use in Visual Basic, Active Server Pages (ASP), and Delphi.
Since DTO is a library of dual interface COM objects, there are two ways of working with these objects in Visual Basic. If you are using Active Server Pages, you must use the second method. The first and preferred method is to add the type library to the project. This method allows VB to do type checking and provides the developer with useful drop down options for object creation and function parameters (Intellisense).
The other method is to use the CreateObject function. This creates objects at run time and therefore lacks type checking and the Intellisense feature.
To add the Pervasive Distributed Tuning Library to a Visual Basic project:
VB is now aware of all the objects included in DTO. All the objects are now browsable. To view the available objects:
You need to use this method when instantiating an object with ASP. The CreateObject syntax looks like this:
Dim my_session as Object ` For DTO Version 2 Set my_session = CreateObject("DTO.DtoSession.2") ` or use DTO Version 1 for compatibility with ` previous DTO applications Set my_session = CreateObject("DTO.DtoSession.1")
Most of the DTO objects can later be obtained from the session object.
There is no special initialization required to use DTO with ASP. However, note the following:
ASP by default does not save state information between calls. You will need to use the Microsoft IIS built-in Session object to preserve object references and variable state.
For example, to initialize a DtoSession object with DTO Version 2:
There are two ways to utilize COM objects in Delphi. As with Visual Basic, the first and preferred set-up method is to import the type library into the Delphi project.
The other method allows COM interfaces to be called directly by using CreateOleObject function. This function will instantiate a single instance of an Automation object.
In order to import the type library and generate the necessary Pascal declarations:
var Result:DTOResult; Session:DTOSession; MySettings:DTOSettings; MyCategories:DTOCategories; MyCategory:DTOCategory; i:integer; begin Session:=CoDTOSession.Create; Result:=Session.Connect ('ServerName','UserName','Password'); MyCategories:=Session.Categories; for i:=1 to MyCategories.Count do MyCategory:=MyCategories.Item[i]; end;
|
Chapter contents
Prev topic: Objects Model and Objects Relationship
|