Skip to content

Other Databases

When connecting to other, non-discussed databases, a database configuration file may need to be created.

Database Configuration File

The first step in creating a database configuration file is determining its name. The name of the database-specific configuration file is <database_name>.int, where <database_name> is the name returned by the backend. You can find out the database name by looking at the table revision, DF_FILE_REVISION, of a table. The table revision is made up of two components: the database name and the version number.

You can see the database name in Database Builder. Open a table from a certain backend, navigate to the parameter tab page of the open table, and look at the Table Revision setting. The database name is the first part of the revision.

For example, a Microsoft Access table shows:

Database Revision Example

The database-specific configuration file for an Access database is Access.int.

The settings you should make in the database configuration file depend on the backend in use. Sometimes, the capabilities of the backend differ from what the ODBC driver returns. You can see the capabilities returned by the ODBC driver by creating a status dump file. Additionally, you need to know what the capabilities of the backend are. Usually, this information can be obtained from the backend’s documentation.

Sample Code to Dump the Status

//***
//*** Procedure: DumpStatus
//*** Purpose  : Dump the status for the connection of the specified table
//***
Procedure DumpStatus Handle hTable
    Handle hoODBC
    Boolean bIsOpen
    String sDriver
    String sDir
    String sSep
    String sDumpFile

    //*** Make sure failure to open does not abort the program
    Send IgnoreError of Error_Object_Id DFERR_CANT_OPEN_DATA_FILE

    //*** Open the table defined in the table number form
    If (hTable <> 0) Begin
        Open hTable
        Move (Found) to bIsOpen
        If (bIsOpen) Begin
            //*** Make sure this is an ODBC table
            Get_Attribute DF_FILE_DRIVER of hTable to sDriver
            If (Uppercase(sDriver) = "ODBC_DRV") Begin
                //*** Get data path and use first directory
                Get psDataPath of (phoWorkspace(ghoApplication)) to sDir
                If (Pos(";", sDir) > 0) Move (Left(sDir, Pos(";",sDir) - 1)) to sDir
                Move (Sysconf(Sysconf_Dir_Separator)) to sSep
                If (Right(sDir, 1) <> sSep) Move (sDir + sSep + "ODBCsts.log") to sDumpFile
                Else Move (sDir + "ODBCsts.log") to sDumpFile
                Set Value of oDumpFileTB to sDumpFile

                //*** Create the dump file
                Get Create U_cODBCHandler to hoODBC
                Send DumpStatus of hoODBC sDumpFile
                Send Destroy of hoODBC
            End
            Else Error 987 "Table is not accessed by the DataFlex ODBC Driver."
            Close hTable
        End
    End

    //*** Make sure failure to open works as it did before this procedure
    Send Trap_Error of Error_Object_Id DFERR_CANT_OPEN_DATA_FILE
End_procedure // DumpStatus