[en] Configuration file for Automation Service can include database connection string replacement commands.
[en] 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.
[en] Connection string replacement logic is defined in the DatabaseConnections.Config
file that is located in the Automation system folder.
-
[en] Open the Automation system folder
%PROGRAMDATA%\NiceLabel\NiceLabel 10
-
[en] Create a file with the name
DatabaseConnections.config
. -
[en] 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>
[en] This sample XML is an example, where an existing trigger contains a connection to the Microsoft SQL server named
mySQLServer
and the database namedmyDatabase
. You want to update the connection string to use the databaseNEW_myDatabase
on the serverNEW_mySQLServer
.[en] Two replacement elements have to be defined – one to change the server name and one to change the database name.
-
[en] Check the existing connection string in your labels, then change the
<Replacement>
content with the correct values.[en] Configuration file defines from-to pairs using its XML structure. The
<Replacement>
element contains one<From>
and one<To>
element. During trigger execution, the "from" string is replaced with the "to" string. You can define as many<Replacement>
elements as necessary.注意
[en] 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.
-
[en] Edit your
product.config
file that is located in%PROGRAMDATA%\NiceLabel\NiceLabel 10
. Add the element/Common/General/UseLocalReplacementStrings
and assign valueTrue
:<?xml version="1.0" encoding="utf-8"?> <configuration> <Common> <General> ... <UseLocalReplacementStrings>True</UseLocalReplacementStrings> </General> </Common> ... </configuration>
-
[en] Restart both Automation services after adding or editing the config files.
-
[en] Repeat steps 1-6 on all computers that run Automation configurations where you want to replace database connection strings.
注意
[en] Database connection string replacement does not change connection strings in your label files. This procedure just overrides connection strings when printing from Automation.