About defining ODBC data sources
Each ODBC data source requires a corresponding ODBC driver
to access it. When you define an ODBC data source, you provide information
about the data source that the driver requires in order to connect
to it. (Defining an ODBC data source is often called configuring the
data source.)
After you prepare to use the data source, you must define
it. To define a data source, use Microsoft’s ODBC Data
Source Administrator utility. This utility can be accessed via the
Control Panel in Windows or via PowerBuilder’s Database painter.
The rest of this section describes what you need to know to
define an ODBC data source in order to access it in the PowerBuilder development
environment.
How PowerBuilder accesses the data source
When you access an ODBC data source in PowerBuilder, there are
several initialization files and registry entries on your computer
that work with the ODBC interface and driver to make the connection.
PBODB80 initialization file
Contents
The PBODB80 initialization file is located in Program FilesSybaseSharedPowerBuilder. PowerBuilder uses
PBODB80.INI to maintain access to extended functionality in the
backend DBMS for which ODBC does not provide an API call. Examples
of extended functionality are SQL syntax or DBMS-specific function
calls.
Editing
In most cases, you should not need to edit the PBODB80 initialization
file. In certain situations, however, you may need to add functions
to the PBODB80 initialization file for your backend DBMS.
For instructions, see Appendix A, “Adding
Functions to the PBODB80 Initialization File”.
ODBCINST registry entries
Contents
The ODBCINST initialization information is located in the HKEY_LOCAL_MACHINESOFTWAREODBCODBCINST.INI
registry key. When you install an ODBC-compliant driver supplied
by Sybase or another vendor, ODBCINST.INI is automatically updated
with a description of the driver. This description includes:
- The DBMS or data source associated
with the driver - The drive and directory of the driver and setup
DLLs (for some data sources, the driver and setup DLLs are the same) - Other driver-specific connection parameters
Editing
You should not
need to edit ODBCINST
information file directly to modify connection information. If your
driver uses the information in the ODBCINST.INI registry key, the
key is automatically updated when you install the driver. This is
true whether the driver is supplied by Sybase or another vendor.
ODBC registry entries
Contents
ODBC initialization information is located in the HKEY_CURRENT_USERSOFTWAREODBCODBC.INI
registry key. When you define a data source for a particular ODBC
driver, the driver writes the values you specify in the ODBC setup
dialog box to the ODBC.INI registry key.
The ODBC.INI key contains a subkey named for each defined
data source. Each subkey contains the values specified for that
data source in the ODBC setup dialog box. The values may vary for
each data source but generally include the following:
- Database
- Driver
- Optional description
- DBMS-specific connection parameters
Editing
You should not
edit the ODBC subkey directly
to modify connection information. Instead, you should use a tool
designed to define ODBC data sources and the ODBC configuration
automatically, such as the ODBC Data Source Administrator.
Database profiles registry entry
Contents
Database profiles for all data sources are stored in the registry
in HKEY_CURRENT_USERSOFTWARESybaseEA Studio4.0
DatabaseProfiles PowerBuilder.
Editing
You should not
need to edit the profiles
directly to modify connection information. These files are updated
automatically when PowerBuilder creates the database profile as part
of the ODBC data source definition.
You can also edit the profile in the Database Profile Setup
dialog box or complete the Database Preferences property sheet in PowerBuilder to
specify other connection parameters stored in the registry. (For
instructions, see Chapter 7, “Setting Additional Connection Parameters”.)
Example
The following example shows a portion of the database profile
for the EAS Demo DB V4 data source:
1 |
DBMS=ODBC |
1 |
Database=EAS Demo DB V4 |
1 |
UserId=dba |
1 |
DatabasePassword= |
1 |
LogPassword= |
1 |
ServerName= |
1 |
LogId= |
1 |
Lock= |
1 |
DbParm=ConnectString='DSN=EAS Demo DB V4; |
1 |
UID=dba;PWD=sql' |
1 |
Prompt=0 |
Values used with ODBC data sources This registry entry example shows the two most important values
in a database profile for an ODBC data source:
- DBMS The DBMS value (ODBC) indicates that you are using the ODBC interface
to connect to the data source. - DBParm The ConnectString DBParm parameter controls your ODBC data
source connection. The connect string must
specify
the DSN (data source name) value, which tells ODBC which data source
you want to access. When you select a database profile to connect
to a data source, ODBC looks in the ODBC.INI registry key for a
subkey that corresponds to the data source name in your profile.
ODBC then uses the information in the subkey to load the required
libraries to connect to the data source. The connect string can
also contain the UID (user ID) and PWD (password) values needed
to access the data source.
About defining multiple data sources for the same
data
When you define an ODBC data source in PowerBuilder, each data
source name must be unique. You can, however, define multiple data
sources that access the same data, as long as the data sources have
unique names.
For example, assume that your data source is an Adaptive Server Anywhere database
located in C:ASA7.0SALES.DB. Depending on your
application, you may want to specify different sets of connection
parameters for accessing the database–for example, using
different passwords and user IDs.
To do this, you can define two ODBC data sources named Sales1
and Sales2 that specify the same database (C:ASA7.0SALES.DB)
but different user IDs and passwords. When you connect to the data
source using a profile created for either of these data sources,
you are using different connection parameters to access the same
data.
Displaying Help for ODBC drivers
The online Help for ODBC drivers in PowerBuilder is provided
by the driver vendors. It gives help on:
- Completing the ODBC setup dialog box to define the
data source - Using the ODBC driver to access the data source
Help for any ODBC driver
Use the following procedure to display vendor-supplied Help
when you are in the ODBC setup dialog box for any
ODBC
driver supplied with PowerBuilder.
To display Help for any ODBC driver:
-
Click the Help button in the ODBC setup
dialog box for your driver.A Help window displays, describing features in the setup dialog
box. -
Click the Contents button in the Help window to
display additional Help topics for this driver.Another Help window displays, listing the topics you can view.
-
Click an underlined topic to display its Help
window.
Selecting an ODBC translator
What is an ODBC translator?
The ODBC drivers supplied with PowerBuilder allow you to specify
a translator when you define the data source. An ODBC
translator is a DLL that translates data passing between
an application and a data source. Typically, translators are used
to translate data from one character set to another.
What you do
Follow these steps to select a translator for your ODBC driver.
To select a translator when using an ODBC driver:
-
In the ODBC setup dialog box for your driver,
display the Select Translator dialog box.The way you display the Select Translator
dialog box for Sybase-supplied ODBC drivers depends on the driver
and Windows platform you are using. Click Help in your driver’s
setup dialog box for instructions on displaying the Select Translator
dialog box.The Select Translator dialog box displays. The translators
listed in this dialog box are determined by the values in your ODBCINST.INI
registry key. -
Select a translator to use from the Installed
Translators list.If you need help using the Select Translator dialog box, click
Help. -
Click OK.
The Select Translator dialog box closes and the driver performs
the translation.