Distributed Tuning Objects Introduction
The following topics introduce the functions that comprise the Zen Distributed Tuning Objects:
You can also go directly to more detailed information on using DTO in Zen:
What is DTO?
Distributed Tuning Objects (DTO throughout the rest of this document) are the COM wrapper for the Zen Distributed Tuning Interface (DTI throughout the rest of this document). DTO is a collection of objects encapsulating DTI. DTO also contains some features that go beyond the capabilities of DTI such as the ability to start and stop the database engines.
DTO enables developers to develop a range of useful, customized server administration tools and interfaces quickly and easily. The power and flexibility of DTO can be applied to the full range of database management and database definition tasks such as production, performance tuning, and metadata administration.
DTO is implemented as a dual interface, in-process server. The developer can use any OLE Automation controller, or create a COM client using many programming languages such as:
Microsoft Visual Basic
Microsoft Active Server Pages (ASP)
Microsoft Visual C++
Embarcadero Delphi
Embarcadero C++ Builder
DTO Objects Model and Objects Relationship
For the purpose of this manual, DTO classes are arranged in the following functional categories:
Connection
In order to be able to configure and monitor the behavior of the database engine, users musts first connect to it. This category provides functionality necessary to connect to and disconnect from database engines.
The DtoSession object manages the connection to a database engine.
Monitoring and Diagnostic
This category provides functionality to monitor Zen servers and clients and provides diagnostic information.
The DtoMonitor object and its descendents provide server monitoring and diagnostic information. You can also obtain engine information directly from DtoSession with the DtoEngineInformation object.
Configuration
This category allows the user to configure the Zen engines and clients. The DtoCategories collection and its descendents provide this functionality.
You can also add and remove product licenses using the DtoLicenseMgr object.
Catalog and Dictionary
Functionality grouped in this category allows users to create new databases, new data dictionaries and also define and drop tables, columns, and indexes.
The DtoDictionary class and its descendents provide catalog functionality.
DTO Object Tree
Many DTO objects are exposed as properties of other DTO objects. The relationship provides developers with a logical structure that simplifies programming with automation controllers. You can reference objects using the familiar dot notation to access properties and methods.
The DTO object tree contains three main branches, logically grouping objects for Configuration, Monitor and Catalog.
DTO Versions
The following table shows usage information regarding the two versions of DTO:
Item
DTO2
DTO1
 
x86
x64
x86
DLL name
DTO2.DLL
w64DTO2.DLL
DTO.DLL
Library
DTOLib2
DTOLib
ProgID of DtoSession
DTO.DtoSession.2
DTO.DtoSession.1
ProgID of DtoDatabase
DTO.DtoDatabase.2
DTO.DtoDatabase.1
ProgID of DtoDictionary
DTO.DtoDictionary.2
DTO.DtoDictionary.1
DTO2
A new DLL was released with Zen V8 SDK that added objects and new properties to existing objects. In order to maintain backward compatibility, a new DLL was created instead of adding this to the previous DTO.DLL. Both are installed and registered with Zen SDK and you can use either one to develop DTO applications. Using the previous DTO.DLL may be important to you if you cannot recompile your application to use the new DLL. However, if you continue to use the previous DTO.DLL, you cannot use the new objects or some new properties that were added to existing objects. DTO2.DLL supports 32-bit development environments, including the .NET framework.
W64DTO2
The Zen v11 SP1 SDK added 64-bit support for 64-bit environments, including the .NET framework.
In order to utilize DTO for 64-bit applications, you will need to install the 64-bit server or client with your 64-bit application. Installing the 64-bit server or client installs the 64-bit version (W64DTO2.DLL), whereas installing the 32-bit server or client installs the 32-bit version (DTO2.DLL or DTO.DLL), as described in the previous table.
Understanding How Applications and DLLs Interact
To better understand how applications and DLLs interact, we will examine the following scenarios.
Assuming we have the following three DLLs:
DTO.DLL
DTO2.DLL
W64DTO2.DLL
And the following application executables:
ANYCPU.EXE
X86.EXE
X64.EXE
The following tables illustrate the results when you try and run the application executables and DLLs together, on 32- and 64-bit machines.
32-bit Machine Process
Application Executable
Runs as
DTO.DLL
DTO2.DLL
W64DTO2.DLL
ANYCPU.EXE
32-bit process
Loads
Loads
BadImageFormat Exception
X86.EXE
32-bit process
Loads
Loads
BadImageFormat Exception
X64.EXE
BadImageFormat Exception
64-bit Machine Process
Application Executable
Runs as
DTO.DLL
DTO2.DLL
W64DTO2.DLL
ANYCPU.EXE
64-bit process
BadImageFormat Exception
BadImageFormat Exception
Loads
X86.EXE
32-bit process
Loads
Loads
BadImageFormat Exception
X64.EXE
64-bit process
BadImageFormat Exception
BadImageFormat Exception
Loads
Getting Started with DTO
This topic describes how to set up DTO for use in Visual Basic, Active Server Pages (ASP), and Delphi.
Delphi
Visual Basic
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.
Adding a Reference to DTO to a Project
To add the Distributed Tuning Library to a Visual Basic project:
1. Select References from the Project menu.
2. Scroll through the available entries and select the Pervasive Distributed Tuning Library 1.0 or Pervasive Distributed Tuning Library 2.0 check boxes. For more information on the difference, see DTO2.
3. Click OK.
VB is now aware of all the objects included in DTO. All the objects are now browsable. To view the available objects:
1. Select Object Browser from the View menu. Alternatively, you can press F2.
2. Select DTOLib or DTOLib2 from the list of available libraries depending if you want DTO Version 1 or 2, respectively. For more information on the difference, see DTO2.
Using the CreateObject Function
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.
Active Server Pages
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:
Set Session("my_session") = Server.CreateObject("DTO.DtoSession.2")
Delphi
COM objects in Delphi are used in two ways. As with Visual Basic, the first and preferred setup 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.
Importing the DTO Type Library into a Delphi project
In order to import the type library and generate the necessary Pascal declarations:
1. Select Project | Import Type Library.
2. The Import Type Library dialog box displays the type libraries registered on the system. Choose Pervasive Distributed Tuning Library 1.0 or Pervasive Distributed Tuning Library 2.0
3. Enter a location of pascal unit in Unit directory name and press Create Unit. The file DTOLib_TLB.pas or DTOLib2_TLB.pasfile will be created and included in the project, depending on whether you use DTO version 1 or 2.
4. Then include the generated pascal unit to the main file by including the following line:
uses DTOLib2_TLB; // Dto Version 2
uses DTOLib_TLB;  // Dto Version 1
Example of Using 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;
Example of Using Direct COM Calls
Example:
var
Session, Categories, Category: Variant;
I: Integer;
begin
Session := CreateOleObject('DTO.DtoSession');
Session.Connect('ServerName','UserName','Password');
Categories := Session.Categories;
for I := 1 to Categories.Count do
Category := Categories.Item[I];
end;
DTO Object Summary
The Distributed Tuning Objects Reference is divided into three chapters by functional grouping. The objects in each chapter are listed in this section.
Connection Object
DtoSession
The DtoSession object is the core of DTO. It is through the DtoSession object that an application connects to Zen servers. A DTO application creates a DtoSession object and uses the Connect method when a session is required on a specific database server.
Configuration Objects
DtoCategory
Object DtoCategory and collection DtoCategories group database engine settings and allow the user further access to the DtoSetting objects.
DtoSetting
Object DtoSetting and collection DtoSettings expose the specific settings for the database engines, the communication managers, and the local requester components and allow the user to change these settings. Each category typically exposes a collection of settings.
DtoSelectionItem
Object DtoSelectionItem and collection DtoSelectionItems contain the full range of items in a setting where selection is allowed. DtoSetting.AllPossibleSelections returns a collection of all possible values for a given setting.
DtoServices
Object DtoServices allows the user to start and stop Zen database services, and to query the current status of a service.
DtoLicenseMgr
Object DtoLicenseMgr (DTO2) allows for adding and removing licenses, as well as viewing product information .
Monitoring Objects
DtoMonitor
Object DtoMonitor allows the user to retrieve real-time status information of the database engine and other related services.
Also exposed in DtoMonitor object is information about resource usage such as current, peak, and maximum settings for file handles, open files, and licenses. A peak value is the maximum value since the last engine restart.
DtoOpenFile
Object DtoOpenFile and collection DtoOpenFiles contain information about active files. This allows user to monitor file access by determining how many files are open, what users have them open, and other related information.
DtoFileHandle
Object DtoFileHandle and collection DtoFileHandles expose user name/agent ID, connection, task, site, network address, open mode, record lock type, wait state, and transaction state.
DtoMkdeClient
Object DtoMkdeClient and collection DtoMkdeClients expose the information about active clients. For a particular client, you can query to see if there is an active session of that client and if so, get data about that session and optionally terminate the client.
DtoMkdeClientHandle
Object DtoMkdeClientHandle and collection DtoMkdeClientHandles expose handle information, including the name and associated information for each file.
DtoMkdeVersion
Object DtoMkdeVersion (DTO2) exposes the major and minor version, build number, and target operating system of the Zen engine.
DtoEngineInformation
Object DtoEngineInformation (DTO2) exposes the major and minor version, DTI API version, and other server and client information.
DtoSqlClient
Object DtoSqlClient and collection DtoSqlClients expose the information about active SQL users such as count and list of active SQL users, and detail information about each client.
DtoCommStat
Object DtoCommStat exposes the communication statistics. You can query the current, peak, and maximum values where appropriate.
DtoProtocolStat
Object DtoProtocolStat and collection DtoProtocolStats expose information regarding each network protocol running on a server.
Database and Dictionary Objects
DtoDatabase
Object DtoDatabase and collection DtoDatabases are responsible for managing the database catalog information, such as database name, database flags, security, and table definitions.
DtoDSN
Object DtoDSN and collection DtoDSNs represent the Zen DSNs on your server. They can be used to create new DSNs and to manage existing Zen ODBC DSNs.
DtoDictionary (deprecated)
Object DtoDictionary is the root object for all of the operations affecting dictionary files. Use this object to open a dictionary, create a dictionary, get table information add a table or drop a table.
The preferred method of accessing the Tables collection is using the DtoDatabase object.
DtoTable
Object DtoTable and collection DtoTables are responsible for managing the table information, such as name, columns, and indexes.
DtoColumn
Object DtoColumn and collection DtoColumns are responsible for managing the information about the columns.
DtoIndex
Object DtoIndex and collection DtoIndexes expose the indexes defined for a table.
DtoSegment
Object DtoSegment and collection DtoSegments contain information on the segments of a given index for a table.
Working with DTO Collections
Collections are objects that contain other objects.
Instantiating a Collection
Visual Basic
Use the Set keyword to set a variable to the collection object.
Dim result as DtoResult
Dim my_session as New DtoSession
Dim my_databases as DtoDatabases
result = my_session.Connect("myserver", "username", "pw")
 
if not(result=0) Then
' error handling for Connect method
end if
 
' Use Set when an object or collection
' is the return type
 
Set my_databases = my_session.Databases
ASP
When using ASP, you normally need to instantiate only two objects directly: DtoSession and DtoDictionary. Instantiating an object with Active Server Pages uses the Create Object syntax on the built-in Server object of IIS.
Set my_session = Server.CreateObject("DTO.DtoSession.2")
Note:  If you want the object to exist between HTTP calls, you must use the IIS built-in object Session to maintain the object state, as shown in the following example.
Set Session("my_session") = Server.CreateObject("DTO.DtoSession.2")
However, if you create new objects, such as databases, DSNs, tables, columns, indexes, or segments, you use this same syntax. The progid for each object follows the convention shown in the preceding example.
For other collections, you can use the Set syntax documented previously for Visual Basic.
Looping through a Collection
Visual Basic
There are two ways to loop through collections in Visual Basic: using a For loop and using a counter.
The following shows the Visual Basic syntax to loop through a collection using a For/Next statement.
' obtain categories collection
Dim my_categories as DtoCategories
Dim category as DtoCategory
Set my_categories = my_session.Categories
 
' loop through collection
For Each category In my_categories
settings = category.Settings
Next
The following shows the Visual Basic syntax to loop through a collection using a counter.
Dim column as DtoColumn
Dim table as DtoTable
Set table = dictionary.Tables("Billing")
Dim i as long
for i=1 to table.Columns.count
set column=table.Columns(i)
'perform operations with this column
next i
ASP
Here is sample ASP code that displays a list of categories for Zen configuration:
<%
Set Session("my_session") = Server.CreateObject("DTO.DtoSession.2")
result = Session("my_session").Connect("myserver", "username", "pw")
' Error handling for Connect method not shown
 
Set my_categories = Session("my_session").Categories
' Now loop through and print categories in a unordered HTML list (<UL></UL>)
%>
 
<ul>
<% For each category in my_categories %>
 
<% ' The = (equal) sign displays the variable %>
<% ' in the HTML stream and is a short cut %>
<% ' for the Response.Write() built-in %>
<% ' VBScript method. %>
 
<li><%=cat.CategoryId> - <%=cat.Name%></li>
 
<% Next %>
</ul>
Obtaining Number of Members
Visual Basic
Use the Count property to determine the number of objects in the collection.
Dim num_items as Integer
Dim my_session as New DtoSession
Dim result as DtoResult
result = my_session.Connect("myserver", "username", "pw")
' Error handling for Connect method not shown
Set my_databases = my_session.Databases
num_items = my_databases.Count
ASP
Use the Count property to determine the number of objects in the collection.
<%
Set Session("my_session") = Server.CreateObject("DTO.DtoSession.2")
result = Session("my_session").Connect("myserver", "username", "pw")
' Error handling for Connect method not shown
Set my_databases = Session("my_session").Databases
num_items = my_databases.Count
' Now write output to HTML stream
Response.Write("<p>Number of databases = " & num_items)
%>
Obtaining a Specific Member
Visual Basic and ASP
Use the Item property to obtain a specific member object of a collection.
Elements within collections can be accessed using their ordinals. Some collections support accessing elements using the element's unique property, such as name. All ordinals are 1-based.
Since Item is a default property of the collection object, the following two statements are identical:
Collection.Item(index)
Collection(index)
Where to Find DTO Samples
The Zen SDK includes a complete DTO sample written in Visual Basic. This sample is included in your SDK installation of samples and header files at the following location.
The SDK components, code snippets, and samples are available on the Actian website.
For default locations of Zen files, see Where are the files installed? in Getting Started with Zen.
Also look at the Actian website for other developer information and resources pertaining to the DTO access method.
Last modified date: 10/31/2023