IServerID  Example

 

This example allows selection of a server using the PI-SDK control (server pick list).  The Command1 button retrieves the Server's notion of the Server ID using IServerID.IDFromServer.  The Command2 button calls IServerID.ResetKSTServerID.  The Command4 button will close and reopen the selected server to allow testing of the reset method.  The Command3 button invokes the PISDK Connection dialog to allow adding and examining servers.  

Build the IServerID example as follows:

1. Create a new project and add a reference to the PISDK library.

2. Add a reference to the PI-SDK Control under the Project | Components menu.

3. Add the visual elements as shown in the picture with the names described in the text above.

4. Cut and paste the code below into the project.

Dim cnxn As New Connections

Private Sub Command1_Click()
   On Error GoTo eh
   Dim srv As Server
   Set srv = PISrvPickList1.SelectedServer
   Dim srvID As IServerID
   Set srvID = srv
   Dim strServerID As String
   strServerID = srvID.IDFromServer
   Text1.Text = strServerID
   Exit Sub
eh:
   MsgBox Err.Description
End Sub

Private Sub Command2_Click()
   On Error GoTo eh
   Dim srv As Server
   Set srv = PISrvPickList1.SelectedServer
   Dim srvID As IServerID
   Set srvID = srv
   srvID.ResetKSTServerID
   Exit Sub
eh:
   MsgBox Err.Description

End Sub

Private Sub Command3_Click()
   cnxn.ShowConnectionDialog
End Sub

Private Sub Command4_Click()
On Error GoTo eh
   Dim srv As Server
   Set srv = PISrvPickList1.SelectedServer
   If srv.Connected Then srv.Close
   
   srv.Open
   Exit Sub
eh:
   MsgBox Err.Description
End Sub
Enabling Operational Intelligence