DF_DRIVER_CONNECTION_ID

The identifier for a DataFlex connection.

Level

Driver

Supported by

The DataFlex SQL Drivers (SQL Server, DB2 and ODBC), revision 5 and higher

Type

String, temporary

Access

Read Only

Values

Any string

Syntax

Use cli.pkg

 

Get_Attribute DF_DRIVER_CONNECTION_ID of {driverNumber} to {StringVariable}

Driver Configuration Keyword

None

Remarks

We introduced a new concept to define a connection, the "DataFlex connection ID". Basically, this provides a way to give a connection string a logical identification. When specifying the connection, the logical identification is used rather then the actual connection string. This allows a setup where a program using the same set of tables in multiple databases to only have one set of intermediate files. See DataFlex Connection IDs for more information.

Function DriverIndex String sDriver Returns Integer

    String  sCurrentDriver

    Integer iNumberOfDrivers iDriver iCount

 

    Move 0 to iDriver

    Get_Attribute DF_NUMBER_DRIVERS to iNumberOfDrivers

    For iCount From 1 To iNumberOfDrivers

        Get_Attribute DF_DRIVER_NAME of iCount To sCurrentDriver

        If ( Uppercase(sCurrentDriver) = Uppercase(sDriver) ) Begin

            Move iCount to iDriver

        End

    Loop

 

    Function_Return iDriver

End_Function // DriverIndex

 

Procedure ShowConnectionIDs

    Integer iDriver

    Integer iNumConn

    Integer iConn

    String sID

    String sConnString

    Integer iConnOptions

    Get DriverIndex "MSSQLDRV" To iDriver

    If (iDriver = 0) Begin

        Showln "Driver not loaded"

        Procedure_Return

    End

    Get_Attribute DF_DRIVER_NUMBER_CONNECTION_IDS of iDriver to iNumConn

    Showln "Number of connection ids: " iNumConn

    For iConn From 0 to (iNumConn - 1)

        Get_Attribute DF_DRIVER_CONNECTION_ID of iDriver iConn to sID

        Get_Attribute DF_DRIVER_CONNECTION_ID_STRING   of iDriver iConn to sConnString

        Get_Attribute DF_DRIVER_CONNECTION_ID_OPTIONS of iDriver iConn to iConnOptions

        Showln sID ", " sConnString ", " iConnOptions

    Loop

End_Procedure

The sample code above shows the currently defined connection id’s for the DataFlex SQL Driver.