Connect the SDK to the Server

After instantiation of the SDK, connect to one or more servers by providing a valid user name and password for the target Historian server domain. The SDK does not support any other functions until you make a successful connection and authentication. The authenticated user also controls which functions may be performed through the SDK and potentially what data may be accessed.

The following example displays the Visual Basic code for instantiation of the SDK and connection to the target server.
Dim MyServer as Object
'Instantiate The SDK
Set MyServer = CreateObject("iHistorian_SDK.Server")

'Attempt Connection
If Not MyServer.Connect("USGB014", "Fred", "000") Then
Err.Raise 1, "Failed To Connect To USGB014" End If

In the example above, "MyServer" does not receive events from the Historian server. 
In order to receive events, Dim WithEvents MyServer As iHistorian_SDK.Server
'Instantiate The SDK
Set MyServer = New iHistorian_SDK.Server

'Attempt Connection
If Not MyServer.Connect("USGB014", "Fred", "000") Then
Err.Raise 1, "Failed To Connect To USGB014" End If
Note: After each session, disconnect each Server connection prior to exiting the application.