PIServer.Connect Method (String, AFConnectionPreference)
- Last UpdatedNov 18, 2025
- 2 minute read
- PI System
- AF SDK 2024 R2
- Developer
Connects to the server using the specified Access Token to allow sending and retrieving data.
Namespace: OSIsoft.AF.PI
Assembly: OSIsoft.AFSDK (in OSIsoft.AFSDK.dll) Version: 3.1.1.1182
Syntax
public void Connect( string accessToken, AFConnectionPreference preference )
Public Sub Connect ( accessToken As String, preference As AFConnectionPreference ) Dim instance As PIServer Dim accessToken As String Dim preference As AFConnectionPreference instance.Connect(accessToken, preference)
public: void Connect( String^ accessToken, AFConnectionPreference preference )
member Connect : accessToken : string * preference : AFConnectionPreference -> unit
Parameters
- accessToken
- Type: SystemString
The Access Token to use when connecting to the server. - preference
- Type: OSIsoft.AFAFConnectionPreference
The connection preference to use when determining which member of the PICollective is selected for the connection. The default preference can be obtained from Preference property of the this object's ConnectionInfo. The Preference setting will be updated to this value after a successful connection.
Exceptions
| Exception | Condition |
|---|---|
| PIConnectionException | A connection to the PI Data Archive server cannot be made. |