Skip to content

Driver Management

Each managed connection has a driver. When a connection is added, its driver is loaded and registered as needed. Once a driver is loaded and registered, it is never removed. This means that you normally do not need to concern yourself with loading drivers, as adding a connection will do this for you.

Sometimes you need to send API messages to the driver itself. You tend to do this by sending a message to a driver CLI handler or by sending an API message to the driver via an index. The cConnection interface has interfaces to assist in this process.

RegisterDriver

RegisterDriver is used to load and register a managed driver. It is passed the driver name to register. If the driver is not yet loaded, it will load it. If the driver is not yet registered, it will register it. When the driver is registered, a cCLIHandler is created for this object, which may then be accessed using the DriverCLIHandler method. After the driver is registered, the OnDriverRegistered event is sent.

If the driver is already registered, this does nothing. If the driver cannot be found or it does not support managed connections, an error will be raised.

Remember that you will probably never send this message, as this is sent when a connection is added.

OnDriverRegistered

After a driver is registered, OnDriverRegistered is called. This provides the developer a hook that can be used to set driver-related API properties.

Procedure OnDriverRegistered String sDriverId Integer iDriver Handle hoCLIHandler
    // turn off cache if the driver is the DAW MSSQL Driver
    If (sDriverId = "MSSQLDRV") Begin
        Set_Attribute DF_DRIVER_USE_CACHE of iDriver to False
    End
End_Procedure

DriverIndex

DriverIndex returns the index for a loaded driver. All loaded drivers, managed and unmanaged, have a driver index.

A loaded driver may not be registered. This might happen if the driver does not support managed connections or if a pre-loaded driver has not yet been registered. You can use the DriverCLIHandler method to determine if a driver is registered.

The DriverIndex can be used to communicate with the driver API interface. The DF_DRIVER_ API interfaces require that you pass a driver number. DriverIndex returns that number.

DriverCLIHandler

This returns a handle for the CLI object associated with the passed driver. When a driver is registered, a cCLIHandler object is created for this driver. DriverCLIHandler can also be used to test if a driver is registered. If it returns 0, the driver is not registered, although it may be loaded (check DriverIndex for that). The ConnectionIdCLIHandler method can be used to access this same CLI object via a connection ID.

LoadedDrivers

LoadedDrivers returns a string array of all loaded drivers, both managed and unmanaged. This is a low-level helper function and is not related to Connection IDs.

DriverServerNames

DriverServerNames returns an array of logged-in servers for the passed driver. This is a low-level helper function and is not related to Connection IDs.

Previous Topic

Managing Connection Information

Next Topic

Error Handling in Managed Connections