Skip to content

duduyoyo/OLEDB4OPC

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

OLEDB4OPC

Introduce the lowest level DB programming in Classic OPC for performance reason!

Microsoft has revived OLE DB in recent years with new release of OLE DB driver. The new features like encryption in this new driver make it an ideal candidate of database programming in Cloud era, especially with performance in mind. But, due to its long backward history, it is hard to find a good example to apply it with Classic OPC. This solution will fill the gap by showing how to use OLE DB programming in Classic OPC DA server, and insert/select data to/from database quickly. OPC data callback feature is used in this example.

Pre-requiste

1. Download the latest OLE DB driver from Microsoft site.

2. In SQL Server create a TEST database, and then create a table by running following query,

use TEST;

CREATE TABLE [dbo].[OPCDA](

[Tag] [nvarchar](50) NOT NULL,

[Value] [real] NOT NULL,

[Time] [datetime] NOT NULL,

[Quality] [tinyint] NOT NULL

);

3. Double click OPC.udl to establish a database connection to SQL Server. Only leave minimum attributes to satisfy backward compatibility need as already shown in this file.

4. Install an OPC DA server in the same box.

5. To run as a 64-bit application you need register 64-bit proxy dlls first from command line, like "C:\Windows\System32\regsvr32 x64Proxy\opccomn_ps.dll" and "C:\Windows\System32\regsvr32 x64Proxy\opcproxy.dll"

Compile and run

This console project is compiled and run under 64-bit debug mode for Visual Studio 2022.

Console output

Related contribution

WebSocket4OPC, a renovative approach to access plant data anyway and anywhere!

About

Lowest level DB programming for OPC Classic

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published