Print Document Using Database Triggers (Video - 7:27) Follow


BarTender Content Team

Applies to: BarTender 2016 and later.


The goal of this example is to create a Database Integration that uses an update to a SQL Server database table to trigger printing a BarTender document. The Integration Service passes the table's data into the document's named data sources and then prints each record.


A company has a backend database containing data they wish to print on their labels. A table or view can be generated so that when new records or data are added, it will trigger a printed label. This eliminates the need to utilize a middleware application to interface between the database and BarTender.


The following procedures describe how to set up, deploy, and verify the integration for the scenario outlined above.

Set Up the Data Files

  1. Create a SQL Server database table with the following entries:
  2. Name the database "TestDb" and name the table "Table_1".

Create the BarTender Document

  1. Open BarTender.
  2. From the File menu, select New to open the New Document Wizard.
  3. Select Blank Template, and then click Finish to close the New Document Wizard. A new document appears in BarTender.
  4. From the File menu, select Print to open the Print dialog.
  5. From the Name dropdown list, select the printer you want to use, and then click Close to close the Print dialog.
  6. Create two named data sources:
    1. On the Data Sources tab of the Toolbox, select Named Data Sources.
    2. From the Named Data Sources context menu, select Create Named Data Source to open the Create Named Data Source Wizard.
    3. In the Name field, type CompanyName.
    4. Click Finish.
    5. Click Close to close the Named Data Sources dialog.
    6. In the Toolbox, select Named Data Sources again and repeat the process. This time, create a named data source called IDNumber.
  7. From the Create menu, add a single-line text object to your document.
  8. From the Create menu, add a Code 128 type barcode to your document.
  9. From the text object's context menu, select Properties to open the Text Properties dialog.
  10. In the left Navigation Pane under Data Sources, select the data source you just created, currently called Sample Text.
  11. If it's not already open, click the Data Source tab.
  12. At the right of Name, click to open the Change Data Source Name Wizard.
  13. On the wizard, select Link to existing named data source.
  14. From the list of named data sources, select CompanyName.
  15. Click OK to close the Change Data Source Name Wizard.
  16. Click Close to close the Text Properties dialog.
  17. From the barcode object's context menu, select Properties to open the BarCode Properties dialog.
  18. In the left Navigation Pane, select the data source you just created, currently called 12345678.
  19. Repeat steps 11-16, this time connecting the barcode object to the IDNumber named data source.
  20. From the File menu, select Save As, and save the BarTender document under the name CompanyList.btw.

Create the Integration

  1. Open Integration Builder.
  2. Click Create New Integration to open the New Integration dialog.
  3. Select Database, and click OK to close the New Integration dialog.
  4. In the Database Integration pane, select Integration.
  5. In the Properties pane, enter the Name of your integration as "CompanyList".
  6. From the Start Integration dropdown list, select Automatic.
  7. Under User Account, specify user credentials. See Print document using an empty file for details.
  8. In the Database Integration pane, select New Record Detection.
  9. In the Properties pane, click Database Connection Setup to open the Database Setup Wizard.
  10. Select Microsoft SQL Server and click Next.
  11. At the right of Server, enter the server name.
  12. Select Specify user name and password (Database Authentication) and enter the username and password you wish to use.
  13. From the Database dropdown list, select the name of the SQL Server database you created the table "TestDb" and click Next.
  14. Select Use the wizard to build SQL statement.
  15. Add "TestDB" from the Available Tables list to the Tables to Use list and click Next.
  16. Select Record Browser to verify the correct data has been loaded.  Click OK to complete the connection.
  17. In the Properties pane under New Record Detection Method, select Field has increasing value.
  18. From the Field dropdown list, select ID. Leave the Last value set at 0. This will execute the Integration for any database records after the specified last value and database field.
  19. In the Database Integration pane, expand the Action node and then further expand the For Each Database Record node.
  20. Select the Print Document action.
  21. In the Properties pane, scroll down to the Document section.
  22. At the right of Document, browse to and select the BarTender document you created earlier, CompanyList.btw.
  23. Under Named Data Sources, assign values to the named data sources using the variable database field names.
    • The Name column refers to the named data source set in the BarTender document, and the Value column refers to the actual value sent to the named data source. In this example, it would be the variable database field names of the database you are using in the Integration.

  24. Click  in the top left corner of Integration Builder to save the integration file as DatabaseIntegration.btin.

Test the Integration

  1. At the bottom of the Integration Builder window, click the Test tab.
  2. At the top-right of the Test window, click the Start button.
  3. Since there are 7 new records in the database table, 7 documents should print.
  4. If the integration is working properly, click  in the top left corner of Integration Builder to save the integration file. The integration can now be deployed to Administration Console.

Deploy the Integration

  1. From the Integration Builder toolbar, click  Deploy Integration to open the New Deployment dialog.
  2. In the New Deployment dialog, enter a name and description for your deployment.
  3. Ensure that the Integration File setting lists DatabaseIntegration.btin. Otherwise, click Browse and browse to and select DatabaseIntegration.btin.
  4. For Target Servers, add the server(s) you want to deploy the integration file to.
  5. Specify the desired Error Handling settings.
  6. Click OK to close the dialog and deploy the integration file.
  7. Administration Console will open on the Integrations node, displaying your integration.


Do you have feedback or questions on this article? We encourage you to post them on our Community Forums