[Previous][Up][Next] Reference for unit 'sqldb' (#fcl)

Using the universal TSQLConnector type

The normal procedure when using SQLDB is to use one of the TSQLConnection descendent components. When the database backend changes, another descendent of TSQLConnection must be used. When using a lot of different connection types and components, this may be confusing and a lot of work.

There is a universal connector component TSQLConnector which can connect to any database supported by SQLDB: it works as a proxy. Behind the scenes it uses a normal TSQLConnection descendent to do the real work. All this happens transparenty to the user code, the universal connector acts and works like any normal connection component.

The type of database can be set in its ConnectorType property. By setting the ConnectorType property, the connector knows which TSQLConnection descendent must be created.

Each TSQLConnection descendent registers itself with a unique name in the initialization section of the unit implementing it: this is the name that should be specified in the ConnectorType of the universal connection. The list of available connections can be retrieved with the GetConnectionList call.

From this mechanism it follows that before a particular connection type can be used, its definition must be present in the list of connector types. This means that the unit of the connection type (ibconnection, pqconnection etc.) must be included in the uses clause of the program file: if it is not included, the connection type will not be registered, and it will not be available for use in the universal connector.

The universal connector only exposes the properties common to all connection types (the ones in TSQLConnection). It does not expose properties for all the properties available in specific TSQLConnection descendents. This means that if connection-specific options must be used, they must be included in the Params property of the universal connector in the form Name=Value. When the actual connection instance is created, the connection-specific properties will be set from the specified parameters.

See also



An abstract class representing a connection to a SQL Database



Universal connection component

Documentation generated on: Sep 28 2017