2 Replies Latest reply on Oct 11, 2016 12:55 PM by gregor

    How to use PI-SDK to change the default server?


      I see in the SDK documentation how you can connect a new server definition and set it to the default.

      If I want to change the default server to one of the current servers in the known servers table, will using the 'Add' method with an existing server name create a new definition for the server, or update the existing one ?  Or is there some other method that I am not seeing in the SDK reference materials that will allow the default server to be set, rather than just read ?

      Thanks !

        • Re: How to use PI-SDK to change the default server?

          Hi Randall,


          I believe that the Servers.DefaultServer property is both read/write and can be set to an existing Server object.

          1 of 1 people found this helpful
          • Re: How to use PI-SDK to change the default server?

            Hello Randall,


            Because PI SDK is on its way to deprecation, we recommend using AF SDK with new development projects. There are some exceptions e.g. if you are using VBA.


            The implementation of the Servers object is pretty similar in PI SDK and AF SDK. The Add method requires to specify a new unique name. Because IP address, hostname, FQDN are valid options, the Add method will return an error to the attempt to add a PI Data Archive host that somehow is already referenced in the Known Servers Table (KST).


            Please find a AF SDK code sample below

            String newServer = "myNewDefaultPI";
            PIServers servers = new PIServers();
            Console.WriteLine("Default PI Data Archive host: {0}", servers.DefaultPIServer);
            servers.DefaultPIServer = servers[newServer];
            Console.WriteLine("New default PI Data Archive: {0}", servers.DefaultPIServer);
            3 of 3 people found this helpful