How to assign value via variable to AF attribute in c sharp
There is not just a single option. You could use AFAttribute.SetValue or use AFData.UpdateValue which I would prefer upon SetValue, also because some of the overloads for SetValue are marked as obsolete.
The AF SDK Programming Reference has sample code for AFData.UpdateValues which is a method which allows to update multiple data items (Attributes) at once but would also work with just a single update.
Please let us know if you have additional questions after reviewing the sample code.
You may also like Developing Applications with PI AF SDK course available through OSIsoft Learning.
If the attribute uses the PIPoint data reference, I personally would use attribute.Data.UpdateValue. However, in a majority of cases where the attribute has a data reference, the data is already provided by that data reference so I would question whether I really need to update the source data.
If the attribute is static, that is does not have a data reference, I personally would use attribute.SetValue.
Retrieving data ...