Starting ODBC Driver Manager Trace in a PowerBuilder
application
To start ODBC Driver Manager Trace in a PowerBuilder
application, you must specify certain values for the ConnectOption
DBParm parameter in the appropriate script. For example, you might
include them in the script that opens the application.
You can specify the required ConnectOption values in a
PowerBuilder script by:
-
(Recommended) Copying the PowerScript ConnectOption DBParm
syntax from the Preview tab in the Database Profile Setup dialog
box into your script -
Coding PowerScript to set a value for the DBParm property of
the Transaction object -
Reading the DBParm values from an external text file
For more about using Transaction objects to communicate with a
database in a PowerBuilder application, see the section called “Using Transaction Objects” in Application Techniques.
About the ConnectOption DBParm
parameter
ConnectOption includes several parameters, two of which control
the operation of ODBC Driver Manager Trace for any ODBC-compatible
driver you are using in PowerBuilder.
|
Parameter |
Description |
|---|---|
|
SQL_OPT_TRACE |
Purpose Starts or stops Values The values you can
|
|
SQL_OPT_TRACEFILE |
Purpose Specifies the name Values You can specify any For information about the location of |
Copying ConnectOption syntax from the
Preview tab
The easiest way to start ODBC Driver Manager Trace in a
PowerBuilder application script is to copy the PowerScript
ConnectString DBParm syntax from the Preview tab in the Database
Profile Setup – ODBC dialog box into your script, modifying the
default Transaction object name (SQLCA) if necessary.
As you complete the Database Profile Setup dialog box in the
development environment, PowerBuilder generates the correct connection
syntax on the Preview tab. Therefore, copying the syntax directly from
the Preview tab into your script ensures that it is accurate.
To copy ConnectOption syntax from the Preview tab into your
script:
-
On the Options tab in the Database Profile Setup – ODBC
dialog box for your connection, select the Trace ODBC API Calls
check box and (optionally) specify a log file in the Trace File
box to start ODBC Driver Manager Trace. -
Click Apply to save your changes to the Options tab without
closing the dialog box. -
Click the Preview tab.
The correct PowerScript syntax for ODBC Driver Manager Trace
and other selected options displays in the Database Connection
Syntax box.The following example shows the PowerScript syntax that
starts ODBC Driver Manager Trace and sends output to the file
C:TEMPODBCTRCE.LOG.123456// Profile EmployeeSQLCA.DBMS = "ODBC"SQLCA.AutoCommit = FalseSQLCA.DBParm = "Connectstring='DSN=Employee',ConnectOption='SQL_OPT_TRACE,SQL_OPT_TRACE_ON;SQL_OPT_TRACEFILE,c: empodbctrce.log'" -
Select the SQLCA.DBParm line and any other syntax you want
to copy to your script and click Copy.PowerBuilder copies the selected text to the
clipboard. -
Paste the selected text from the Preview tab into your
script, modifying the default Transaction object name (SQLCA) if
necessary.
Coding PowerScript to set a value for the
DBParm property
Another way to start ODBC Driver Manager Trace in a
PowerBuilder application script is to include the ConnectOption
parameters that control tracing as values for the DBParm property of
the Transaction object.
To start ODBC Driver Manager Trace by setting the DBParm
property:
-
In your application script, set the SQL_OPT_TRACE and
(optionally) SQL_OPT_TRACEFILE ConnectOption parameters to start
the trace and to specify a nondefault trace file,
respectively.For example, the following statement starts ODBC Driver
Manager Trace in your application and sends output to a file named
MYTRACE.LOG. Insert a comma to separate the ConnectString and
ConnectOption values.This example assumes you are using the default Transaction
object SQLCA, but you can also define your own Transaction
object.123SQLCA.DBParm="ConnectString='DSN=Test;UID=PB;PWD=xyz',ConnectOption='SQL_OPT_TRACE,SQL_OPT_TRACE_ON;SQL_OPT_TRACEFILE,C:TRC.LOG'"
Reading the DBParm value from an external
text file
As an alternative to setting the DBParm property in your
PowerBuilder application script, you can use the PowerScript
ProfileString function to read DBParm values from a specified section
of an external text file, such as an application-specific
initialization file.
This assumes that the DBParm value read from your initialization
file includes the ConnectOption parameter to start ODBC Driver Manager
Trace, as shown in the preceding example.
To start ODBC Driver Manager Trace by reading DBParm values
from an external text file:
-
Use the following PowerScript syntax to specify the
ProfileString function with the DBParm property:1SQLCA.dbParm = ProfileString (file, section, variable, default_value)For example, the following statement in a
PowerBuilder script reads the DBParm values from the [Database]
section of the APP.INI file:1SQLCA.dbParm = ProfileString("APP.INI","Database","DBParm","")