How to log OPC Unified Architecture data changes into a SQL Server database
See also: QuickOPC.NET: How to log OPC Alarms and Events notifications into an XML file, QuickOPC.NET: How to log OPC Data Access item changes into an XML file.
It is often required that a status of certain process variable is logged into a SQL database. Following example shows how to do that with QuickOPC:
The database creation script is here:
And (part of) the resulting data may look like this:
This example is included with the product. Please use the example from the product itself for the most up-to-date code of the example.
General information about integration of QuickOPC and Microsoft SQL Server is here.
OPC Alarms and Events notifications can be logged using the same approach, with EasyAEClient component.
Update: The original example (SimpleLogToSql) stores values of all data types in a single SQL_VARIANT column. We are now including two additional examples of SQL logging with the product:
- LogAsString: Values of all data types are stored in a single NVARCHAR column.
- LogAsUnion: Values of all data types are stored in separate columns.