RAD Studio
ContentsIndex
PreviousUpNext
Configuring TSQL Connection

The first step when working with a unidirectional dataset is to connect it to a database server. At designtime, once a dataset has an active connection to a database server, the Object Inspector can provide drop-down lists of values for other properties. For example, when representing a stored procedure, you must have an active connection before the Object Inspector can list what stored procedures are available on the server. The connection to a database server is represented by a separate TSQLConnection component. You work with TSQLConnection like any other database connection component.

Metaprocedure: Configuring a TSQL Connection

  1. Choose FileNewOther. The New Items dialog appears.
  2. In the New Items dialog, select Delphi Projects and double-click VCL Forms Application. The Windows Designer displays.
  3. From the dbExpress category of the Tool Palette, drag a TSQLConnection component to the form.
  4. Identify the driver (see steps below).
  5. Specify connection parameters (see steps below).
  6. Identify a database connection (see steps below).
  7. Display and use the dbExpress Connection Editor (see steps below).

To identify the driver

  1. Select the TSQLConnection component.
  2. In the Object Inspector, set the DriverName property, to an installed dbExpress driver.
  3. Identify the files associated with the driver name. Select any of the following:
    • The dbExpress driver
    • The dynamic link library
Note: The relationship between the dbExpress driver or dynamic link library and the database name is stored in a file called dbxdrivers.ini
, which is updated when you install a dbExpress driver. The SQL connection component looks the dbExpress driver and the dynamic-link library up in dbxdrivers.ini when given the value of DriverName. When you set the DriverName property, TSQLConnection automatically sets the LibraryName and VendorLib properties to the names of the associated dlls. Once LibraryName and VendorLib have been set, your application does not need to rely on dbxdrivers.ini.

To specify a connection parameter

  1. Double-click on the Params property in the Object Inspector to edit the parameters using Value List Editor at designtime.
  2. Use the Params.Values property to assign values to individual parameters at run time.

To identify a database connection

  1. Set the ConnectionName property to a valid connection name. This automatically sets the DriverName and Params properties.
  2. Edit the Params property to change the saved set of parameter values.
  3. Set the LoadParamsOnConnect property to True to develop your application using one database and deploy it using another. This causes TSQLConnection to automatically set DriverName and Params to the values associated with ConnectionName in dbxconnections.ini when the connection is opened.
  4. Call the LoadParamsFromIniFile method. This method sets DriverName and Params to the values associated with ConnectionName in dbxconnections.ini (or in another file that you specify). You might choose to use this method if you want to then override certain parameter values before opening the connection.

To display the Connection Editor

  1. Double-click the TSQLConnection component. The dbExpress Connection Editor appears, with a drop-down drivers list, a list of connection names for the currently selected driver, and a connection parameters table for the currently selected connection name.
  2. From the Driver Name drop-down list, select a driver to indicate the connection to use.
  3. From the Connection Name list, select a connection name.
  4. Choose the configuration that you want.
  5. Click the Test Connection button to check for a valid configuration.

To define and modify connections using the Connection Editor

  1. To edit the currently selected named connections in dbxconnections.ini, edit the parameter values in the parameter table.
  2. Click OK. The new parameter values are saved to dbxconnections.ini.
  3. Click the Add Connection button to define a new connection. The New Connection dialog appears.
  4. In the New Connection dialog box, set the Driver Name and the Connection Name.
  5. Click OK.
  6. Click the Delete Connection button to delete the currently selected named connection from dbxconnections.ini.
  7. Click the Rename Connection button to change the name of the currently selected named connection.

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!