Configuration file for Automation Service can include database connection string replacement commands.
You can configure the service to replace certain parts of a connection string while the trigger is running. This enables a single instance of Automation to run the same configuration, but actually use a different database server for database related functionality. This allows the user to configure triggers in development environments and run them in production environments without any changes in the configuration.
Connection string replacement logic is defined in the
DatabaseConnections.Config file that is located in the Automation system folder.
Open the Automation system folder
Create a file with the name
Open the newly created file DatabaseConnections.config in a text editor and enter the sample content:
<?xml version="1.0" encoding="UTF-8"?> <DatabaseConnectionReplacements> <Replacement> <From>Data Source=mySQLServer</From> <To>Data Source=NEW_mySQLServer</To> </Replacement> <Replacement> <From>Initial Catalog=myDatabase</From> <To>Initial Catalog=NEW_myDatabase</To> </Replacement> </DatabaseConnectionReplacements>
This sample XML is an example, where an existing trigger contains a connection to the Microsoft SQL server named
mySQLServerand the database named
myDatabase. You want to update the connection string to use the database
NEW_myDatabaseon the server
Two replacement elements have to be defined – one to change the server name and one to change the database name.
Check the existing connection string in your labels, then change the
<Replacement>content with the correct values.
Configuration file defines from-to pairs using its XML structure. The
<Replacement>element contains one
<To>element. During trigger execution, the "from" string is replaced with the "to" string. You can define as many
<Replacement>elements as necessary.
Some connection strings use Server=servername while others use Data Source=servername. If you use the same database, you don't have to enter database names.
product.configfile that is located in
%PROGRAMDATA%\NiceLabel\NiceLabel 10. Add the element
/Common/General/UseLocalReplacementStringsand assign value
<?xml version="1.0" encoding="utf-8"?> <configuration> <Common> <General> ... <UseLocalReplacementStrings>True</UseLocalReplacementStrings> </General> </Common> ... </configuration>
Restart both Automation services after adding or editing the config files.
Repeat steps 1-6 on all computers that run Automation configurations where you want to replace database connection strings.
Database connection string replacement does not change connection strings in your label files. This procedure just overrides connection strings when printing from Automation.