PreviousNext
Help > Easycom .NET > System.Data.EasycomClient namespace > EacCommand > EacCommand properties > EacCommand.Parameters
EacCommand.Parameters

 

public.EacParameterCollection Parameters [ get]

 

This property is used to define or consult the parameters collection.

 

Note: When using SQL stored procedures, it is recommended to define the parameters before preparing the command object. In this case the definition of the parameters can be partial or with different data type, but must correspond to the right number of parameters, and the specified data type and sizes must be compatible with the actual types and sizes.

When using Easycom stored procedures, there is no need to define the parameters before calling Prepare() method.

 

After the EacCommand.Prepare method call, the Parameters collection is updated.

 

 

Example (VB.NET):

mycmd.CommandType = CommandType.StoredProcedure

mycmd.CommandText = "S_ORD_SUM"

With mycmd.Parameters.Add("CUSTOMER_NO", DbType.Int32, 4)

.Direction = ParameterDirection.Input

.Scale = 0

End With

With mycmd.Parameters.Add("total_orders", DbType.Decimal, 8)

.Direction = ParameterDirection.Output

.Scale = 2

End With

With mycmd.Parameters.Add("num_orders", DbType.Int32, 4)

.Direction = ParameterDirection.Output

.Scale = 0

End With

 

mycmd.Prepare()

 

Example (C#):

EacCommand mycmd = new EacCommand();

mycmd.CommandType = CommandType.StoredProcedure;

mycmd.CommandText = "S_ORD_SUM";

EacParameter param1 = mycmd.Parameters.Add("CUSTOMER_NO", DbType.Int32, 4);

param1.Direction = ParameterDirection.Input;

param1.Scale = 0;

param1.Value = 1001;

 

EacParameter param2 = mycmd.Parameters.Add("total_orders", DbType.Decimal, 8);

param2.Direction = ParameterDirection.Output;

param2.Scale = 0;

 

EacParameter param3 = mycmd.Parameters.Add("num_orders", DbType.Int32, 4);

param3.Direction = ParameterDirection.Output;

param3.Scale = 0;

mycmd.Prepare();

 

// Another way to pass value to parameter

mycmd.Parameters["CUSTOMER_NO"].Value = 1001

 

 

 

 

 

Note:

 

When you add a parameter, it is also possible to affect a value for the parameter. Therefore, it is not necessary to specify the type, because the type of the “value” is used.

 

For a String parameter:

 

mycmd.Parameters.Add(new EacParameter("COMPANY", "AURA"));

 

For an integer:

 

Int32 cust_id = 777;

mycmd.Parameters.Add("CUSTOMER_NO", cust_id);