Specifies the parameters required to connect to an ODBC data source. PowerBuilder uses these parameters to connect to the database.
ODBC
The ConnectString syntax displays on a single line. You must enclose the entire ConnectString in single quotes and separate parameters within the ConnectString with semicolons.
ConnectString = 'DSN = data_source_name; {UID = user_ID; PWD = password; driver_specific_parameters}'
Parameter |
Description |
---|---|
data_source_name |
A name that identifies the data source. |
user_ID |
(Optional) The user ID required to connect to the data source. |
password |
(Optional) The password required by user_ID to connect to the data source. |
driver_specific_parameters |
(Optional) Any other driver-specific parameters required to connect. For example, some ODBC drivers specify the data source directory
here. If you are using the PB DataDirect Btrieve ODBC driver, you
can specify the value The PB DataDirect Text ODBC driver uses this parameter to specify the century date. You can specify the value CB = 50 here to indicate that years from 00 to 49 be prefixed with '20' and years from 50 to 99 be prefixed with '19'. |
None
PowerBuilder generates the ConnectString automatically when you define an ODBC data source and copies it to the Preview box in the Database Profile Setup dialog box. This happens before you connect to the data source in PowerBuilder.
Therefore, you do not have to enter the ConnectString yourself when defining an ODBC data source. However, you might need to edit the ConnectString value in the Database Profile Setup dialog box.
You can change the ConnectString parameter if necessary by editing it in the Database Profile Setup dialog box. For example, if you change the name of an existing ODBC data source, edit its database profile to update the connect string with the new DSN (data source name) value.
This example shows a connect string for an ODBC data source that contains the data source name (DSN=Sales), user ID (UID=dba), and password (PWD=sql). Parameters within the connect string are separated by semicolons.
Database profile On the Connection tab in the Database Profile Setup dialog box, select Sales from the Data Source drop-down list, select the User ID check box and type dba, and select the Password check box and type sql.
Application Type the following in code:
SQLCA.DBParm = "ConnectString ='DSN=Sales;UID=dba; PWD=sql'"
This example shows a connect string for a Btrieve data source accessed with the PB DataDirect Btrieve ODBC driver. The connect string consists of two parameters: DSN and CDB (to create a new Scalable SQL data dictionary). Parameters within the connect string are separated by semicolons.
Database profile Select Btrieve from the DataSource drop-down list box on the Connection tab in the Database Profile Setup dialog box, and type the following in the Driver-Specific Parameters box:
CDB=1
Application To specify this statement in code, type the following:
SQLCA.DBParm = "ConnectString ='DSN=Btrieve;CDB=1'"