PreviousNext
Help > Easycom .NET > System.Data.EasycomClient namespace > EacCommand > Example 1: call a program
Example 1: call a program

 

Into this example, the EASYCOMXMP/RPCSAMPLE program is called.

This example is provided with demo samples.

Parameters are filled by using value filled within textbox component.

OP1 is an input parameter.
STR1 is an input parameter.
OP2 is an input/output parameter. After call, OP2 = OP2 + OP1.
STR2 is an input/output parameter. After call, STR2= STR1.
OP3 is an output parameter. After call, OP3 = OP1 * OP2.

Using easyConn As System.Data.EasycomClient.EacConnection = New  System.Data.EasycomClient.EacConnection()

easyConn.ConnectionString = "Server=power8;User Id=aura;Password=aura;Init Libl=easycomxmp"

            easyConn.Open()

 

Using easyComm As System.Data.EasycomClient.EacCommand = New System.Data.EasycomClient.EacCommand()

 

                With easyComm

 

                    .Connection = easyConn

                    .CommandType = CommandType.StoredProcedure

                    .CommandText = "*PGM/RPCSAMPLE"

 

                    With .Parameters.Add("OP1", DbType.Double, 1)

                        .Direction = ParameterDirection.Input

                        .Value = OP1.Text

                    End With

                    With .Parameters.Add("STR1", DbType.StringFixedLength, 1)

                        .Direction = ParameterDirection.Input

                        .Value = STR1.Text

                    End With

                    With .Parameters.Add("OP2", DbType.Double, 1)

                        .Direction = ParameterDirection.InputOutput

                        .Value = OP2.Text

                    End With

                    With .Parameters.Add("STR2", DbType.StringFixedLength, 1)

                        .Direction = ParameterDirection.InputOutput

                        .Value = STR2.Text

                    End With

                    With .Parameters.Add("OP3", DbType.Double, 1)

                        .Direction = ParameterDirection.Output

                    End With

 

                End With

 

                easyComm.Prepare()

                easyComm.ExecuteNonQuery()

 

                OP1.Text = easyComm.Parameters.Item(0).Value.ToString()

                STR1.Text = easyComm.Parameters.Item(1).Value.ToString()

                OP2.Text = easyComm.Parameters.Item(2).Value.ToString()

                STR2.Text = easyComm.Parameters.Item(3).Value.ToString()

                OP3.Text = easyComm.Parameters.Item(4).Value.ToString()

 

            End Using

            easyConn.Close()

 

        End Using