MDS Global INI File

While the mds.ini file controls information specific to each data folder, mds_global.ini contains settings with a broader scope. The location of the mds_global.ini file is up to you. The first mds_global.ini file found on the usual Path is used. We recommend placing the mds_global.ini file in the same location as the access dll and license (.cfg) file.

These locations are searched in order:

  • Current folder

  • Folder where the dll was loaded from

  • Folder where the exe was loaded from

  • System Path

  • Driver Installation bin folder

All mds_global.ini settings are listed in the table below. Settings are grouped by category: Tracing, Locking, Performance and Miscellaneous. The value marked with an asterisk (*) is the default.

Sample mds_global.ini

Each piece is optional.

[SQL_BTR]
;Tracing
TRACE_ON=c:\trace\sql_btr.tra
TRACE_LEVEL=0
TRACE_FLUSH=no
;Locking
SERVER_SIDE_LOCKING=yes
SQL_LOCKS=no

[ORA_BTR]
;Location of the debug trace file
TRACE_ON = c:\trace\ora_btr.tra
TRACE_LEVEL = 0
TRACE_FLUSH=no
;Locking
SERVER_SIDE_LOCKING=yes
SQL_LOCKS=no

[PGS_BTR]
;Location of the debug trace file
TRACE_ON = c:\trace\pgs_btr.tra
TRACE_LEVEL = 0
TRACE_FLUSH=no
;Locking
SERVER_SIDE_LOCKING=yes
SQL_LOCKS=no

A semi-colon (;) at the beginning of the line in the mds_global.ini file indicates that line is a comment and is ignored. A setting is assigned in mds_global.ini by entering a value after the equal sign (e.g., Trace_On = c:\trace\sql_btr.tra). Spaces are ignored before and after the equal sign. Leaving a value empty means use the driver’s default value. All settings and values are case insensitive.

Entries under a specific heading (e.g., heading [SQL_BTR]) are only used for that driver (e.g., driver MS SQL).

NOTE: A sample mds_global.ini file can be found in the installation folder (<Program Files>\Mertech Data Systems\DB Drivers\Btrieve\bin)

Setting global and folder specific values programmatically

You can set global and folder specific settings programmatically thru a call to MdsSetSetting.

MdsSetSetting

The format for the call is:

MdsSetSetting(foldername, settingname, value)
  • foldername is the full or relative path to the folder where the msd.ini file would reside (for example, “c:\myapp\ver4\data\cust5”). The folder does not have to exist, it is simply the virtual location for the mds.ini file. If the setting being changed is in the mds_global.ini file, specify NULL for foldername.

  • settingname is any entry in the mds.ini file (for example, INT-Folder) or mds_global.ini file (for example (Trace_Level). Setting names are not case sensitive.

If a call to MdsSetSetting is made to enable TRACE_ON, that should be the last trace setting updated. If a trace is already active, it is stopped and a new file takes over using the latest trace settings.

  • value is the value to be assigned to the setting. If a Password value is provided and it starts with 0x, it is assumed that the password was encrypted using MdsEncryptPassword.

There is no need to specify a Section Name (for example [SQL_BTR]). The assumption is that the setting is for the current driver. All parameters are enclosed in quotes, so the value itself should never include quotes.

Examples:

// (mds.ini) Set the password for data files opened in the cust5 folder
MdsSetSetting("c:\\myapp\\ver4\data\\cust5", "Password", "0xed8ee3e72436da3169")
// (mds_global.ini) Limit buffer output in the trace to just KeyBuffers
MdsSetSetting(NULL, "Trace_Buffers", "kb")

How does MdsSetSetting work?

In the example below global memory settings are highlighted in turquoise, folder-specific settings are highlighted in gray and new or updated settings are shown in red text.

1 When the application starts:

  1. Registry values are read and stored.

Trace_On= c:\trace\sql_btr.tra, Trace_Level=0, TRACE_FLUSH=no, Server_Side_Locking=yes

b) Environment variable values are read and stored, overwriting any existing values.

Trace_On= c:\trace\sql_btr.tra,Trace_Level=1, TRACE_FLUSH=no, Server_Side_Locking=yes

c) mds_global.ini values are read and stored, overwriting any existing values.

Trace_On= c:\tracesql_btr.tra, Trace_Level=1,TRACE_FLUSH=yes, Server_Side_Locking=yes, Trace_Query_Times=yes

2 When the application calls MdsSetSetting (NULL, “Trace_Level”, “2”) to set a global value, any existing global value is overwritten.

Trace_On= c:\trace\sql_btr.tra,Trace_Level=2, TRACE_FLUSH=yes, Server_Side_Locking=yes, Trace_Query_Times=yes

3 When the application calls MdsSetSetting (“c:\myapp\ver4\data\cust5”, “Schema”,’cust5”) to set a folder‑specific setting:

a) If an mds.ini file exists in the specified directory (and the file was not already read when a create or open call was made) then the mds.ini file is read and the values are stored.

c:\myapp\ver4\data\cust5: Server=testserver, Database=testdb

  1. MdsSetSetting is run and in memory values are overwritten.

c:\myapp\ver4\data\cust5: Server=testserver, Database=testdb,Schema=cust5

The values set by MdsSetSetting remain in effect until the process stops.

NOTE: Be careful changing values for Schema, Database, Table-Prefix and Table-Postfix using MdsSetSetting since the changes affect all subsequent create and open calls for the selected directory.

NOTE: If there is an mds.ini file on disk, settings in that file are NOT changed by a call to MdsSetSetting. Values set by MdsSetSetting are not stored on disk.

Example

Below is an example using MdsSetSetting to create a virtual mds.ini file and then using these settings to create and open a new table.

// First, execute an embedded sql call to create new schema 'cust5'

// Next, create a virtual mds.ini file for 'c:\myapp\ver4\data\cust5'
MdsSetSetting("c:\myapp\ver4\data\cust5","INT_Folder","c:\myapp\ver4\data\intfiles_mssql")
MdsSetSetting("c:\myapp\ver4\data\cust5","Server","testserver")
MdsSetSetting("c:\myapp\ver4\data\cust5","Database","testdb")
MdsSetSetting("c:\myapp\ver4\data\cust5","Schema","cust5")
MdsSetSetting("c:\myapp\ver4\data\cust5","User","testuser")
MdsSetSetting("c:\myapp\ver4\data\cust5","Password","password")

// Now, create and open Person.mkd using the virtual mds.ini settings
B_CREATE      "c:\myapp\ver4\data\cust5\Person.mkd"
B_OPEN        "c:\myapp\ver4\data\cust5\Person.mkd"

The INT_Folder setting in the virtual mds.ini directs the application to “c:\myapp\ver4\data\intfiles_mssql” where the Person_mkd.int file is stored.

A sample directory structure is shown below. The cust1, cust2, and cust5 folders (shaded in gray) do not actually exist, they are virtual folders, created in memory by MdsSetSetting to contain a virtual mds.ini file. The application must include calls to MdsSetSetting to create these virtual data folders before it opens or creates any tables for these schemas on the server.

c:\myapp
  ver4
    data
        mds.ini(int-folder=.\intfiles_mssql server=testserver schema=common)
        intfiles_mssql
          person_mkd.int
        cust1
          mds.ini(int-folder=.\intfiles_mssql server=testserver schema=cust1)
        cust2
          mds.ini(int-folder=.\intfiles_mssql server=testserver schema=cust2)
        cust5
          mds.ini(int-folder=.\intfiles_mssql server=testserver schema=cust5)

MdsGetSetting

You can retrieve global and folder specific settings programmatically with a call to MdsGetSetting. The format for the call is:

MdsGetSetting(foldername, settingname, return value)

All settings in the mds_global.ini file and all settings in the mds.ini file (except Password) can be retrieved. Additionally these global settings, displayed at the top of the trace file, can be retrieved:

  • Driver_Info: for example, “SQLBTR 5.2.6900.99”

  • Driver_Location: for example, “C:\myapp\w3btrv7.dll”

  • Process_Info: for example, “C:\myapp\myapp.exe, Process ID 3628, WTS ID 0”

  • Computer_Name: for example, “mycomputer”

  • License_Info: for example, “Serial Number 2000 for 10 users registered to MY COMPANY”

  • Current_Working_Folder: for example, “C:\MyApp”

  • Ini_Location: for example, “C:\MyPath\mds_global.ini”   or  “C:\MyApp\data\mds.ini”

Precedence of configuration settings

Global settings can be set programmatically, in the mds_global.ini file, as environment variables and in the registry (HKEY_CURRENT_USER\SOFTWARE\Mertech Data Systems\DB Drivers\BTR\Driver\version). If a value is not found, the driver uses an internal default. Setting options are listed top to bottom, in descending order of precedence.

  • Runtime call to MdsSetSetting

  • INT file

  • mds.ini file

  • mds_global.ini file

  • Environment variables

  • Registry settings (HKCU then HKLM)

  • Driver defaults

Settings in the INT file override settings in the mds.ini file. This allows you to perhaps migrate one important table to another server or database. During migration, check the Get DatabaseName from Login option for all but the one table. Uncheck the option for the one table of interest. Doing so will cause the database name to be written only to the one INT file. For all but this one table, the Database setting in the mds.ini file will be used.

If the INT file and mds.ini file are both stored in the data directory, the INT-Folder setting in the mds.ini file is ignored and settings in the INT file and mds.ini file are merged. If a setting appears in both files (for example, the target back end tokens), the values in the INT file take precedence.

NOTE: Only one mds.ini file is allowed per data directory.

In the example below the mds.ini file contains INT-Folder=..\INTFILES:

C:\MyApp\Archives
  GLOBAL_DAT.int
  PROJ_DAT.int
  RESOURCE_LIB.int
  INTFILES\
    BILLING_MKD.int
    CLASS_MKD.int
    DEPT_MKD.int
    ENROLLS_MKD.int
    PERSON_MKD.int
  1999\
    mds.ini
    PERSON_MKD.int

When B_OPEN is called

The INT File read

C:\MyApp\Archives\1999\Person.mkd

C:\MyApp\Archives\1999\Person_mkd.int

C:\MyApp\Archives\1999\Billing.mkd

C:\MyApp\Archives\INTFILES\Billing_mkd.int