Setting DBParm parameters
In PowerBuilder, you can set DBParm parameters by doing either
of the following:
- Editing
the Database Profile Setup dialog box for your connection in the development
environment - Specifying connection parameters in an application
script
Setting DBParm parameters in the development environment
Editing database profiles
To set DBParm parameters for a database connection in the PowerBuilder development
environment, you must edit the database profile for that connection.
Character limit for DBParm strings
Strings containing DBParm parameters that you specify in the
Database Profile Setup dialog box for your connection can be up
to 999 characters in length.
This limit applies only to DBParm parameters that you set
in a database profile in the development environment. DBParm strings
specified in PowerBuilder scripts as properties of the Transaction
object are not limited to a specified length.
What
you do
You set DBParm parameters in the Database Profile Setup dialog
box for your connection.
Setting DBParm parameters in a PowerBuilder application script
If you are developing a PowerBuilder application that connects
to a database, you must specify the required connection parameters
in the appropriate script as properties of the default Transaction
object (SQLCA) or a Transaction object that you create. For example,
you might specify connection parameters in the script that opens
the application.
One of the connection parameters you may want to specify in
a script is DBParm. You can do this by:
- (Recommended) Copying PowerScript
DBParm syntax from the Preview tab in the Database Profile Setup
dialog box into your script - Coding PowerScript to set values for the DBParm
property of the Transaction object - Reading DBParm values from an external text file
Copying DBParm syntax fromthe Preview tab
The easiest way to specify DBParm parameters in a PowerBuilder application script
is to copy the PowerScript DBParm syntax from the Preview tab in
the Database Profile Setup dialog box into your script, modifying
the default Transaction object name (SQLCA) if necessary.
As you set DBParm parameters in 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 ensures that you use the
correct PowerScript DBParm syntax in your script.
To copy DBParm syntax from the Preview tab into
your script:
-
On one or more tab pages in the Database
Profile Setup dialog box for your connection, supply values for
any DBParm parameters you want to set.For instructions, see “Setting DBParm parameters
in the development environment”.For example, the Network tab in the Database Profile Setup
– Adaptive Server Enterprise dialog box contains settings for network-related DBParm
parameters that the interface supports. This example shows nondefault
settings for Application Name (corresponds to the AppName DBParm
parameter) and Workstation Name (corresponds to the Host DBParm
parameter):
For information about the DBParm parameters
for your interface and the values to supply, click Help. -
Click Apply to save your changes to the current
tab without closing the Database Profile Setup dialog box. -
Click the Preview tab.
The correct PowerScript DBParm syntax for each selected option
displays in the Database Connection Syntax box. For example:
-
Select one or more lines of text in the Database
Connection Syntax box and click Copy.PowerBuilder copies the selected text to the clipboard.
-
Click OK to close the Database Profile Setup dialog
box. -
Paste the selected text from the Preview tab into
your script, modifying the default Transaction object name (SQLCA)
if necessary.
Coding PowerScript to set values for the DBParm
property
Another way to specify connection parameters in a script is
by coding PowerScript to assign values to properties of the Transaction
object. PowerBuilder uses a special nonvisual object called a Transaction
object to communicate with the database. The default
Transaction object is named SQLCA, which stands for SQL Communications
Area.
SQLCA has 15 properties, 10 of which are used to connect to
your database. One of the 10 connection properties is DBParm. DBParm
contains DBMS-specific parameters that let your application
take advantage of various features supported by the database interface.
To set values for the DBParm property in a PowerBuilder script:
-
Open the application script in which you
want to specify connection parameters.For instructions, see the User’s
Guide
. -
Use the following PowerScript syntax to specify
DBParm parameters. Make sure you separate the DBParm parameters
with commas, and enclose the entire DBParm string in double quotes.1<b>SQLCA.dbParm = "</b><i>parameter_1</i><b>,</b><i> parameter_2</i><b>,</b><i> parameter_n</i>"For example, the following statement in a PowerBuilder script
sets the DBParm property for an ODBC data source named Sales. In
this example, the DBParm property consists of two parameters: ConnectString
and Async.1SQLCA.dbParm="ConnectString='DSN=Sales;UID=PB;1PWD=xyz',Async=1" -
Compile the PowerBuilder script to save your changes.
For instructions, see the User’s
Guide
.
Reading DBParm values from an external text file
As an alternative to setting the DBParm property in a 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.
To read DBParm values from an external text file:
-
Open the application script in which you
want to specify connection parameters.For instructions, see the User’s
Guide
. -
Use the following PowerScript syntax to specify
the ProfileString function with the SQLCA.DBParm
property:1<b>SQLCA.dbParm</b> = <b>ProfileString</b> ( <i>file</i>, <i>section</i>, <i>key</i>, <br /> <i>default</i> )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",<br /> "dbParm","") -
Compile the script to save your changes.
For instructions, see the User’s
Guide
.