QPR Knowledge Base

ConnectToServer

Hide Navigation Pane

ConnectToServer

Previous topic Next topic No expanding text in this topic  

ConnectToServer

Previous topic Next topic JavaScript is required for expanding text Mail us feedback on this topic!  

Comments (...)

Revision history:

Introduced in QPR 7.2.1

 

Creates a connection to the ProcessGuide Application Server. Useful together with the Authenticate command.

 

Synopsis:

 

PGApplication.ConnectToServer(ServerAddress, Port)

 

Parameters:

 

ServerAddress: IP address or hostname of the ProcessGuide Application Server. If this setting is empty, the server address configured in the Development Client is used. String.

Port: Socket port of the ProcessGuide Application Server. If this is 0, the server port configured in the Development Client is used. Integer.

 

Required Rights:

 

None/Administrator. Administrator privileges are needed if the server is changed while a model is open.

 

Return Values:

Below are listed the return values that this function can return:

 

RV_SUCCESS

RV_APPLICATION_QUIT_CALLED

RV_CANNOT_CLOSE_MODEL

RV_CANCELLED

RV_CANNOT_CONNECT_TO_SERVER

RV_LOGIN_FAILED (This value is retuned if there was an existing connection to another server and the user was successfully authenticated. For the new connection the authentication is tried with the same information as with the previous connection, and RV_LOGIN_FAILED is returned if this new check fails. Connection to the new server is opened anyway).

 

Example Procedure:

 

Sub ConnectToServerAndAuthenticate()

 Dim iResult

 Dim oModel

 iResult = PGApplication.ConnectToServer("127.0.0.1", 4251)

 If (iResult <> 0) Then

   MsgBox "Could not connect to default server: " + PGApplication.GetErrorMessage(iResult)

 End If

 iResult = PGApplication.Authenticate("qpr", "demo", "")

 If (iResult <> 0) Then

   MsgBox "Authentication failed: " + PGApplication.GetErrorMessage(iResult)

 End If

End Sub

Comments (...)