public void CalculateSalesForRegion(TdConnection cn, Int32 RegionId)
{
// Creating commands that will be used to execute SQL statements
TdCommand cmd1 = cn.CreateCommand();
// The CalculateSalesForRegion stored procedure has the
// following parameters:
// in RegionId Integer
// out Rank Integer
// out SalesForRegion Decimal(38, 2)
// out PercentOfTotalSales Decimal(7, 4)
cmd1.CommandText = "CaculateSalesForRegion";
cmd1.CommandType = System.Data.CommandType.StoredProcedure;
// Setting up parameters to return sales information for the
// specified region
//
// Parameter for the RegionId
Cmd1.Parameters.Add(null, TdType.Integer, 0,
System.Data.ParameterDirection.Input,
true, 0, 0, null, System.Data.DataRowVersion.Default, RegionId);
// Parameter for the Rank
cmd1.Parameters.Add(null, TdType.Integer, 0,
System.Data.ParameterDirection.Output,
true, 0, 0, null, System.Data.DataRowVersion.Default, null);
// Parameter for the SalesForRegion
cmd1.Parameters.Add(null, TdType.Decimal, 0,
System.Data.ParameterDirection.Output,
true, 38, 2, null, System.Data.DataRowVersion.Default, null);
// Parameter for the PercentOfTotalSales
cmd1.Parameters.Add(null, TdType.Decimal, 0,
System.Data.ParameterDirection.Output,
true, 7, 4, null, System.Data.DataRowVersion.Default, null);
// Execute the Stored Procedure
cmd1.ExecuteNonQuery();
// Retrieve the data for each of the out parameters
// Getting the data returned for the Rank
Int32 rank = cmd1.Parameters[1].Value;
// Getting the data returned for the SalesForRegion
// In the instance this parameter was defined as a
// DECIMAL(38,2). If the TdParameter.Value property is
// accessed an OverFlowException will be thrown.
TdDecimal salesForRegion = cmd1.Parameters[2].ProviderSpecificValue;
// Getting the data returned for the PercentOfTotalSales
// Since the parameter is defined as a Decimal(7,4) an
// application can either retrieve the data using the
// TdParameter.ProviderSpecificValue or TdParameter.Value property.
// ProviderSpecificValue will contain a TdDecimal structure.
// Value will contains a System.Decimal structure.
TdDecimal tdPercentOfTotalSales = cmdl.Parameters[3].TdValue;
System.Decimal sysPercentOfTotalSales = cmd1.Parameters[3].Value;
//
// CONTINUE PROCESSING THE DATA RETURNED FROM THE STORED PROCEDURE
//
cmd1.Dispose();
}