QPR Knowledge Base 2017.1

ConnectToServer

ConnectToServer

Previous topic Next topic No directory for this topic  

ConnectToServer

Previous topic Next topic Topic directory requires JavaScript Mail us feedback on this topic!  

Revision history:

Introduced in QPR 7.2.1

Last changed in QPR 2012.2

 

Creates a connection to the QPR BizArchitecture Server. Useful together with the Authenticate command.

 

Synopsis:

 

PGApplication.ConnectToServer(ServerAddress, Port)

 

Parameters:

 

ServerAddress: IP address or hostname of the QPR BizArchitecture Server. If this setting is empty, the server address configured in the QPR Modeling Client is used. String.

Port: Socket port of the QPR BizArchitecture Server. If this is 0, the server port configured in the QPR Modeling 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).

RV_FUNCTION_CANNOT_BE_USED_IN_VALIDATION_SCRIPT

 

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