Skip to the content.

DBModifications

DBModifications can be used to

The target data referred to by DBMapper and DBAction (data is the DML SQL statement(s)) is specified by special Range names, any other definitions (environment, target database, etc.) is stored in a custom property of the workbook having the same name as the target range.

Examples for the usage of DBMapper can be found in the DBMapperTests.xlsx Workbook.

Create DBModifiers

You can create the three DB Modifiers by using the cell context menu:
image

The DBModifier creation/editing is shown below (examples already filled, when activated on a blank cell all entries are empty):
(some features cannot be set in the dialogs, e.g. a customized confirmation text for the “Ask for execution” dialog, this is done with Edit DBModifier Definitions, see below)

DB Mappers are created/edited with the following dialog:

image

You can always edit these parameters by selecting a cell in the DB Mapper area and invoking the context menu again.

The range that is used for holding the data to be stored can be identified in three different ways:

The clickable Hyperlink shows the range address of the data range, a named offset formula is displayed after the address:
image

DB Actions are created/edited with following dialog:

image

Example for parametrization: DB Action cell contains INSERT INTO Test (Col1,Col2,Col3,Col4) VALUES(!1!,!2!,!3!,!4!); Cols num params string: 1; Cols num params date: 3; Parameter Range Names: paramC1,paramD1,paramE1,paramF1

Where cells in param range paramC1, paramD1, paramE1 and paramF1 contain the parameters being replaced into the template string. The first range is being replaced into !1!, the second in !2!, and so on. Parameter ranges are read row-wise from left to right (as usual) and need to have the same size. Assuming param range paramC1, paramD1 and paramE1 contain numbers, the parameters in paramC1 are replaced in the template as strings (surrounded by quotes), parameters in paramD1 are unquoted numbers and parameters in paramE1 are replaced in the template as date values (using the default DBDate formating).
Date values (formatted as dates) are automatically recognized, there is no need to explicitly mark them with Cols num params date

You can always edit these parameters by selecting a cell in the range of the DB Action area and invoking the context menu again.

DB Sequences are created/edited with following dialog:

image

As DB Sequences have no Range with data/definitions, invoking the context menu always creates new DB Sequences. You can edit existing DB Sequences by Ctrl-Shift clicking the Execute DBModifier Groups dropdown menus or by Ctrl-Shift clicking the created command-buttons.

Edit DBModifier Definitions

All DBModifier definitions (done in XML) can be viewed by clicking the dialogBox Launcher on the right bottom corner of the Execute DBModifier Ribbon Group together with Ctrl and Shift. This opens the Edit DBModifier Definitions Window:
image

Here you can edit the definitions directly and also insert hidden features like the customized confirmation text in the element confirmText.

The DBModifiers can be executed either

… using the Execute DBModifier Groups dropdown menus..
image

… or using command-buttons that were generated with the creation dialogs (the name of the control box has to be the same as the DBModifier definition/DBModifier Range)..

… or be done on saving the Workbook.

… or by issuing the VBA command result = Application.Run("executeDBModif", <DBModifierName>, <headlessFlag>), where <DBModifierName> is the name of the DB Modifier including the type (so DBMapperemployee or DBActionpublishersDelete) and <headlessFlag> is a boolean flag indicating whether any user-interaction (as controllable by the Addin) should be avoided, all errors collected in nonInteractiveErrMsgs and returned in the result of the call.

You can edit the DBModifiers either by Ctrl-Shift clicking the Execute DBModifier Groups dropdown menus..
.. or by Ctrl-Shift clicking the created command-buttons.
.. or by using the Insert/Edit DBFunc/DBModif context menu within a DBMapper or DBAction range.

Additional macro functions available for setting/accessing settings

By issuing the VBA command Application.Run("setExecutionParam", Param, Value), where Param is the name of the parameter and Value is the value it should be set to, following settings can be set via VBA:

By issuing the VBA command result = Application.Run("getExecutionParam", Param), where Param is the name of the parameter the current settings of the following parameters are returned:

Additional settings (“hidden” as they are not available in creation dialogs)

Following Settings of DBModifiers can only be edited in the Edit DBModifier Definitions Window:

Settings

Following Settings in DBAddin.xll.config or the referred DBAddinCentral.config or DBaddinUser.config affect the behaviour of DBModifiers:

    <add key="CmdTimeout" value="30" />
    <add key="CnnTimeout" value="15" />
    <add key="DefaultEnvironment" value="3" />
    <add key="DontChangeEnvironment" value="False" />
    <add key="DBMapperCUDFlagStyle" value="TableStyleLight11" />
    <add key="DBMapperStandardStyle" value="TableStyleLight9" />
    <add key="DebugAddin" value="False" />
    <add key="maxNumberMassChange" value="10" />
    <add key="connIDPrefixDBtype" value="MSSQL" />
    <add key="DBSheetAutoname" value="True" />

Explanation: