Connection Settings and Connection Strings

As you create a new dbExpress application (or open an existing one), and select the SQLConnection component editor (the shortcut menu of the component) you'll immediately see something different from the past:

The Connection editor command (Edit Connection Properties) and the corresponding dialog box are gone, and so has the dialog box with the list of installed drivers. You now have two choices for modifying the dbExpress configuration: The first is to manually edit the dbxdrivers.ini and dbxcon-nections.ini files or and the second is to use the SQLConnection component, its properties, and its new component editor commands. In particular, after you've selected a connection, you can choose from:

• Reload connection parameters will copy the dbxconnections.ini setting to the SQLConnection component for the current configuration. Notice that when the settings have been modified, compared to the original version, the ConnectionName property in the Object Inspector will have an asterisk after its name, indicating a modified set of connection data:

SQLConnectlonl TSQLConnection I Properties | Events I_

Connected

ConnectionName*

Driver

False

IBCON NECTIQN InterBase

  • On the other hand, Save connection parameters will update the dbxconnections.ini with the local settings for the current configuration
  • Add ConnectionString Param will add an extra property to the component, with the complete configuration saved in a single string property, something very handy for configuring the status based on an external INI file or some other configuration settings.
  • Once you've added a connection string, this command will replaced with the commands Refresh ConnectionString Param and Remove ConnectionString Param.

For the specific demo, adding the connection string parameter will add a ConnectionString line to the Params property, with the following content (which I've split on to multiple lines for readability, while it has to be in a single line because it is part of a TStringList):

DelegateConnection=dbxpoolconnection,

DriverName=INTERBASE,

DRIVERUNIT=DBXDynalink,

DRIVERPACKAGELOADER=TDBXDynalinkDriverLoader,

DRIVERPACKAGE=DBXCommonDriver110.bpl,

DRIVERASSEMBLYLOADER=

Borland.Data.TDBXDynalinkDriverLoader, DRIVERASSEMBLY=Borland.Data.DbxCommonDriver, Version=11.0.5000.0, Culture=neutral,

PublicKeyToken=a91a7c5705831a4f,

GETDRIVERFUNC=getSQLDriverINTERBASE,

DATABASE=..\CodeGear Shared\Data\Employee.GDB,

ROLENAME=RoleName,

USER_NAME=sysdba,

PASSWORD=masterkey,

SERVERCHARSET=,

SQLDIALECT=3,

BLOBSIZE=-1,

COMMITRETAIN=False,

WAITONLOCKS=True,

ERRORRESOURCEFILE=,

LOCALECODE=0000,

INTERBASE TRANSISOLATION=ReadCommited, TRIM CHAR=False

Notice that this one-line configuration setting includes standard database settings (in the last part), driver configuration settings, the actual database to connect to, and even delegate driver information.

This new approach is based on a new internal data structure, the TConnectionData persistent class, that can be accessed using the new ConnectionData read-only property of the SQLConnection component. This class stores all configuration settings in an internal TBDXProperties list, can refer to a further TConnectionData structure with a delegate connection, and has support methods like:

procedure UpdateProperties(NewProperties: TStrings);

procedure AddProperties(NewProperties: TStrings);

procedure ReloadProperties;

procedure RefreshProperties;

As an example I've used this property to extract the connection string from the ConnectionData (information also available in the connection Params property). I've written this code in the OnExecute event handler action that I've added to the ActionManager component of the program:

procedure TForm1.ActionGetInfoExecute(Sender: TObject); begi n

ShowMessage (SQLConnectionl.ConnectionData. Properties [ 'ConnectionString']);

Was this article helpful?

0 0
Project Management Made Easy

Project Management Made Easy

What you need to know about… Project Management Made Easy! Project management consists of more than just a large building project and can encompass small projects as well. No matter what the size of your project, you need to have some sort of project management. How you manage your project has everything to do with its outcome.

Get My Free Ebook


Responses

  • Ajay
    What is dbxpoolconnection?
    5 months ago

Post a comment