2 of 2 people found this helpful
Before we start, it is good to point out that you don’t necessary need to use PI AF SDK in order to communicate with a SQL Server. In some situations, you might want to just connect to the SQL Server directly using ADO.NET Data Provider or Entity Framework.
If you want to connect to SQL Server though PI AF SDK, you should use AFTables and there are two options:
- Link the table – which will save the connection string on the AF database and the client will use it in order to connect to the SQL Server. The advantage of this method is that you always get updated data since the data is not duplicated.
- Import the table – this will copy the SQL table data to AF. The advantage is performance but the data is duplicated.
There are two interesting videos about this topic on YouTube:
The videos show how to import and link AFTables using PI System Explorer. Below there is an example using PI AF SDK in C#:
Please let us know if this help you get started!
If I understand correctly you are populating a SQL table with the PI Point names? Is this a once off exercise, something that will run often?
To be honest while I've used the AF SDK quite a bit and like it I probably wouldn't both in this case (although it can be done). Have you considered using a tool like SQL Server Integration Services (SSIS) or even T-SQL with the PI OLE DB provider?
If you have to use the AF SDK you would basically need to create a list of the PI Point and the InstrumentTag attribute and then use something like LINQ to get the intersection of the two lists.