Skip to content

Unload_Driver

See Also: Load_Driver

Purpose

Unloads a loaded database driver.

Syntax

Unload_Driver
driverName

Where driverName is the name (string) of the database driver. The names of drivers available from Data Access Worldwide are:

  • "DATAFLEX" for the embedded database
  • "DB2_DRV" for the DB2 Driver
  • "DFBTRDRV" for the Pervasive.SQL Driver
  • "MSSQLDRV" for the Microsoft SQL Driver
  • "ODBC_DRV" for the ODBC Driver

What It Does

The Unload_Driver command unloads the specified driver from memory, which may release some system resources. It will also close any open files that use the driver driverName.

Note that you do not need to use this command; if your program terminates without unloading drivers, you will not receive an error message.

Unload_Driver "MSSQLDRV"

In this example, all MS SQL tables are closed, all server connections for that driver are terminated, and the driver is deinitialized.

When a driver is unloaded, the number of drivers (DF_NUMBER_DRIVERS) is decremented immediately, and all drivers numbered higher are automatically decremented. So this code does not work:

Integer iDriverCount iDriver
String sName
Get_Attribute DF_NUMBER_DRIVERS to iDriverCount
For iDriver From 1 to iDriverCount
    Get_Attribute DF_DRIVER_NAME of iDriver to sName
    If (sName <> "DATAFLEX") Begin
        Unload_Driver sName
    End
Loop

While this code does:

Integer iDriver iDrivers iDriverCount iDriversToUnload
String sName
String[] sDriversToUnload
Get_Attribute DF_NUMBER_DRIVERS to iDriverCount
For iDriver from 1 to iDriverCount
    Get_Attribute DF_DRIVER_NAME of iDriver to sName
    If (sName <> "DATAFLEX") Begin
        Move sName to sDriversToUnload[iDriversToUnload]
        Increment iDriversToUnload
    End
Loop
For iDriver from 0 to (iDriversToUnload - 1)
    Unload_Driver sDriversToUnload[iDriver]
Loop

Notes

  • The embedded database ("DATAFLEX") driver is always loaded and cannot be unloaded.
  • It is not necessary to unload one driver before loading another; multiple drivers can be loaded at the same time.