AddTag Method (HistorianAccess)
- Last UpdatedAug 21, 2026
- 2 minute read
'Declaration
Public Function AddTag( _
ByVal tagInformation As HistorianTag, _
ByRef tagKey As UInteger, _
ByRef error As HistorianAccessError _
) As Boolean
'Usage
Dim instance As HistorianAccess
Dim tagInformation As HistorianTag
Dim tagKey As UInteger
Dim error As HistorianAccessError
Dim value As Boolean
value = instance.AddTag(tagInformation, tagKey, error)
public bool AddTag(
HistorianTag tagInformation,
out uint tagKey,
out HistorianAccessError error
)
public:
bool AddTag(
HistorianTag^ tagInformation,
[Out] uint tagKey,
[Out] HistorianAccessError^ error
)
Parameters
- tagInformation
- This is the object of HistorianTag. It contains tag configuration information to be stored on the server.
- tagKey
- Contains the tag key successfully added to the server or cache.
- error
- The object of HistorianAccessError. Stored with the error information, if any.
Return Value
The AddTag() method adds tag information to the server or local cache. When the server is available, the tag data is stored in the server. If the server is not available, the tag data is cached locally and synchronized once the server is available. If the same tag is added twice from the same client, the same tag key is returned.
The AddTag() method gets the tag key after the method succeeds and returns error information if any error occurs. Possible reasons for an error could be unknownClient, validationFailed, and a corresponding error code from the HCAL.
The tagKey value returned by the AddTag() method is valid only within the current historian connection until it gets closed. It should never be reused by other historian connections.
The managed HCAL application is responsible to remember the tagKey value returned by the AddTag() method, which should be used later for sending values.
Make sure to call this method only after establishing a connection.
The HistorianTag class provides two constructors. One has no arguments and the other requires the tag name and data type. Only the TagName and TagDataType are required to be specified. All other properties get initialized by the HistorianTag constructor to default values.