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 Application Techniques.
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 ODBC Driver Manager Trace in PowerBuilder. |
SQL_OPT_TRACEFILE |
Purpose Specifies the name of the trace file where you want to send the output of ODBC Driver Manager Trace. PowerBuilder appends the output to the trace file you specify until you stop the trace. To display the trace file, you can use the File Editor (in PowerBuilder) or any text editor (outside PowerBuilder). Values You can specify any filename for the trace file, following the naming conventions of your operating system. By default, if tracing is on and you have not specified a trace file, PowerBuilder sends ODBC Driver Manager Trace output to a file named SQL.LOG. For information about the location of SQL.LOG on different platforms, see “About ODBC Driver Manager Trace”. |
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:\TEMP\ODBCTRCE.LOG.
// Profile Employee
SQLCA.DBMS = "ODBC"
SQLCA.AutoCommit = False
SQLCA.DBParm = "Connectstring='DSN=Employee',
ConnectOption='SQL_OPT_TRACE,SQL_OPT_TRACE_ON;
SQL_OPT_TRACEFILE,c:\temp\odbctrce.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.
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.
SQLCA.DBParm="ConnectString=’DSN=Test;UID=PB; PWD=xyz’,ConnectOption=’SQL_OPT_TRACE, SQL_OPT_TRACE_ON;SQL_OPT_TRACEFILE,C:\TRC.LOG’"
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:
SQLCA.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:
SQLCA.dbParm =
ProfileString("APP.INI","Database","DBParm","")