Connecting to a database
To establish or change a database connection in PowerBuilder,
use a database profile. You can select the database profile for
the database you want to access in the Database Profiles dialog
box.
Using the Database painter to select a database profile You can also select the database profile for the database
you want to access from the Database painter’s Objects
view. However, this method uses more system resources than using
the Database Profile dialog box.
Selecting a database profile
You can select a database profile from the Database Profiles
dialog box.
To connect to a database using the Database Profiles
dialog box:
-
Click the Database Profile button in the
PowerBar.or
Select Tools>Database Profile from the PowerBar.
Database Profile button If your PowerBar does not include the Database Profile button,
use the customize feature to add the button to the PowerBar. Having
the Database Profile button on your PowerBar is useful if you frequently
switch connections between different databases. For instructions
on customizing toolbars, see the User’s Guide
.The Database Profiles dialog box displays, listing your installed
database interfaces.Where the interface list comes from When you run the Setup program, it updates the Vendors list
in the registry with the interfaces you install. The Database Profiles
dialog box displays the same interfaces that appear in the Vendors
list. -
Click the plus sign (+) to the left of
the interface you are using.or
Double-click the name.
The list expands to display the database profiles defined
for your interface. -
Select the name of the database profile you want
to access and click Connect.or
Display the pop-up menu for a database profile and select
Connect.PowerBuilder connects to the specified database and returns
you to the painter workspace.
Database painter Objects view
You can select a database profile from the Database painter
Objects view.
To connect to a database using the Database painter:
-
Click the Database painter button in the
PowerBar.The Database painter displays. The Objects view lists your
installed database interfaces.Where the interface list comes from When you run the Setup program, it updates the Vendors list
in the registry with the interfaces you install. The Database painter
Objects view displays the same interfaces that appear in the Vendors
list. -
Click the plus sign (+) to the left of
the interface you are using.or
Double-click the name.
The list expands to display the database profiles defined
for your interface. -
Select the name of the database profile you want
to access and click the Connect button.or
Display the pop-up menu for a database profile and select
Connect.
What happens when you connect
Connection parameters
When you connect to a database by selecting its database profile, PowerBuilder writes
the profile name and its connection parameters to the registry key HKEY_CURRENT_USERSoftwareSybasePowerBuilder9.0
DatabaseProfilesPowerBuilder.
Each time you connect to a different database, PowerBuilder overwrites
the “most-recently used” profile name in the registry
with the name for the new database connection.
What you get connected to
When you open a painter that accesses the database, you are
connected to the database you used last. PowerBuilder determines which
database this is by reading the registry.
Specifying passwords in database profiles
As shown in the completed Database Profile Setup dialog box
for Employees, your password does not display
when you specify it in the Database Profile Setup dialog box.
However, when PowerBuilder stores the values for this profile
in the registry, the actual password does display,
albeit in encrypted form, in the DatabasePassword or LogPassword
field.
Suppressing display in the profile registry entry
To suppress password display in the profile registry entry,
do the following when you create a database profile.
To suppress password display in the profile registry
entry:
-
Select the Prompt For Database Information
check box on the Connection tab in the Database Profile Setup dialog
box.This tells PowerBuilder to prompt for any missing information
when you select this profile to connect to the database. -
Leave the Password box blank. Instead, specify
the password in the dialog box that displays to prompt you for additional
information when you connect to the database.
What happens
When you specify the password in response to a prompt instead
of in the Database Profile Setup dialog box, the password does not
display in the registry entry for this profile.
For example, if you do not supply a password in the Database
Profile Setup – Adaptive Server Enterprise dialog box when creating
a database profile, the Client Library Login dialog box displays
to prompt you for the missing information:
Using the Preview tab to connect in a PowerBuilder
application
To access a database in a PowerBuilder application, you must
specify the required connection parameters as properties of the
Transaction object (SQLCA by default) in the appropriate script.
For example, you might specify the connection parameters in the
script that opens the application.
In PowerBuilder, the Preview tab in the Database Profile Setup
dialog box makes it easy to generate accurate PowerScript connection
syntax in the development environment for use in your PowerBuilder
application script.
For instructions on using the Preview tab
to help you connect in a PowerBuilder application, see the section
on using Transaction objects in Application Techniques
.