Phoenix Contact PLCnext
For Phoenix Contact PLCnext controllers, SQL4automation provides two example projects and a dedicated library (SQL4PLCnext). One example project communicates via the standard protocol, the other via the UTF-16 protocol. Both supporting unencrypted and TLS/SSL-encrypted connections. The library can be directly integrated into PLCnext Engineer as a standard function-block library and works on all PLCnext controllers equipped with an Ethernet interface.
Connecting Phoenix Contact PLCnext to SQL Databases, MES, ERP
For Phoenix Contact PLCnext controllers, SQL4automation provides two example projects and the SQL4PLCnext library. One example communicates via the standard protocol, the other via UTF-16. Both support unencrypted and TLS/SSL-encrypted connections. The library is based on IEC 61131-3 and integrates directly into PLCnext Engineer, enabling direct PLC-to-database communication without any middleware or additional hardware.

Integration of the SQL4PLCnext Library
The central function block fbSQL4PLCnext manages the connection to the SQL4automation Connector. It is called cyclically in a dedicated low-priority task (recommended: 10 ms interval, priority 10) and receives parameters including the Connector IP address, port, timeout, and TLS settings. Query results are returned via the shared utSQL4PLCnextInterface data structure, accessible from all tasks in the PLCnext program.
SQL4automation Link Settings
The SQL4automation Connector is operated with the target setting "Standard" for PLCnext controllers (or "UTF-16" for the UTF-16 variant). The project-specific adjustments are made in just a few clicks. For encrypted connections, TLS is enabled directly in the fbSQL4PLCnext block (requires Connector V5.1.0.0 or newer).

Using target settings "UTF-16"

For encrypted connections, select the "Standard"target and enable TLS in the fbSQL4PLCnext block by setting xUseTLS = TRUE andproviding the corresponding identity and trust store names. A Connector version of V5.1.0.0 or newer is required for encrypted communication.
FAQ's
Freuqently Asked Questions to Phoenix Contact PLCnext
Can a Phoenix Contact PLCnext controller connect directly to a SQL database?
Yes. SQL4automation provides the SQL4PLCnext library, which establishes a direct TCP/IP connection from the PLCnext controller to the SQL4automation Connector running on a Windows PC. The Connector handles the ODBC communication with the database. No OPC UA server, no middleware, and no additional hardware are required.
Which PLCnext Engineer version is required for SQL4automation?
PLCnext Engineer 2026.0 or newer is required. The Phoenix Contact manufacturer libraries PLCnextBase_1_7_2.pcwlx (and its sub-libraries PLCnextBase.pcwlx and PLCnextBaseServices.pcwlx) must also be installed before adding SQL4PLCnext to your project. The recommended install path is C:\Users\<user>\Documents\PLCnext Engineer\Libraries.
Does SQL4automation support encrypted communication with PLCnext?
Yes. TLS/SSL encrypted communication is supported from Connector version V5.1.0.0 onwards. Enable it by setting xUseTLS = TRUE in the fbSQL4PLCnext block and providing the Identity Store and Trust Store names configured via the PLCnext web interface. Certificates are generated with OpenSSL and must be in PEM format for PLCnext. Always test without encryption first.
What is the difference between the Standard and UTF-16 example projects?
Both example projects offer identical functionality and use the same fbSQL4PLCnext function block. The only difference is the string encoding in the SQL telegram: the Standard project uses the default encoding, while the UTF-16 project uses UTF-16 encoded strings. Both support encrypted and unencrypted connections. Choose the variant that matches your database or middleware configuration.
In which PLCnext task should the fbSQL4PLCnext block be called?
Place fbSQL4PLCnext in a dedicated low-priority task: tskUncritical, Interval = 10 ms, Priority = 10. This ensures database communication does not interfere with time-critical control tasks. For high-frequency applications, the optional fbSQL4PLCnextConnectionObserver block maintains a persistent connection and sends keep-alive queries to prevent timeout errors during idle periods.
Technical Data
Switch to SQL4automation Now.
Connect industrial controllers directly with SQL databases. Field-proven since 2007 for maximum performance and security, completely without middleware.