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. For how to create a database profile, see Creating a database profile.
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 requires more system resources than using the Database Profiles dialog box.
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 menu bar.
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 Users 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.
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_USER\Software\Sybase\PowerBuilder\17.0\DatabaseProfiles\PowerBuilder.
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.
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.
The three-letter abbreviation for the database interface followed by the name of the database profile displays in PowerBuilder's main title bar. If you are working with a DataWindow object, this visual cue makes it easier to check that you are using the right connection.
For example, if you open the PowerBuilder Code Examples workspace and connect to the Demo database, the title bar displays "pbexamples - ODB [PB Demo DB V2017] - PowerBuilder."
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, 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.
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 called “Working with Transaction objects” in Application Techniques.