I am trying to write a value in PI attribute using SET value function but getting an error as a wrong input format.
Actually i want to write "no data" in PI attribute if the value is null from source.
Is there any solution to handle this?
Sometimes you must be exact with "No Data" instead of "no data". But there are better ways to make your code less prone to break.
First, you could be using the AFSystemStateCode.NoData enumeration instead of the literal "No Data" strings. It makes your intent clear and avoids any capitalization issues. The enumeration is an equivalent of the digital state (code + text), whereas "No Data" is just the text portion.
Then there is the AFValue.CreateSystemNoDataFound method, which creates an AFValue. For the flexibility of other digital states besides "No Data", there is the AFValue.CreateSystemStateValue method.
I suggest you read the Remarks section of the AFAttribute.SetValue method. Additionally, you may consider using the AFData.UpdateValue method. In either case, you would still want to use the AFSystemStateCode.NoData enumeration or the AFValue.CreateSystemNoDataFound or AFValue.CreateSystemStateValue methods.
Going back to your stated problem of SetValue, let's assume you have variables named "attr" and "timestamp". Then you could try:
I am a personal fan of the first way since one day I may decide to use another digital state. All of would have to specify is another AFSystemStateCode enumerated value.
Retrieving data ...