community.borland.com

Article #20193: Changing BDE Driver Settings Programmatically


This document illustrates how to change BDE driver settings programmatically (settings found under “Configuration->Drivers” in the BDE Administrator only). You may need to change BDE driver settings programmatically if, for example, you want to specify the DLL32 setting for the Oracle or MSSAccess driver (to specify oracle 7 or 8, MSAccess 95 or 97), or you want to increase the value of Max DBProcesses for the MSSQL driver.

Note: If you need to change the parameters for anything that can be found on the “Database” tab in BDE administrator, then you should use Tdatabase.Params (not covered in this document).

A BDE driver can be configured at runtime using Tsession.ModifyDriver. The following code changes the Max DBProcesses driver parameter for the MSSQL driver.

Start a new application, drop a Tsession on the form, set autosessionname to true, and add the following code into the OnCreate event handler for the form:

procedure TForm1.FormCreate(Sender: TObject);
var
  DriverParams: TStringList;
begin
  DriverParams := TStringList.Create;
  try
    { add the parameters that you want to change only. The default for
      this param is 31. }
    DriverParams.Add('MAX DBPROCESSES=50'); 
 
   { call modify driver with name of driver and list of params }
     session1.ModifyDriver('MSSQL',DriverParams); 

    { call this if you want to save the changes in the BDE for all 
      applications to use, will only take affect after all BDE applications
      have been unloaded on the system. }
    session1.SaveConfigFile;  
  finally
    DriverParams.Free;
  end;
end;


Be sure to read the documentation for Tsession.ModifyDriver in the online help files-> especially about Tsession.ConfigMode and the scope of ModifyDriver.

Last Modified: 08-DEC-99