In Stadium, it is possible to call stored procedures which return output values, and in turn display these output values in controls.
Scenario: Calculate Currency amount based on Exchange Rate
User enters Amount and Exchange Rate, and then clicks on the Calculate button. A calculated amount is displayed in a Label.
Steps :
Create a DetailsView with 2 Fields – Amount and Exchange Rate. Add a Calculate button and a Label called CalculatedValueLabel. DetailsView will be used to pass input values and Label will be used to display output values.
To the button Click event, add a variable (I named it calculateVariable).
Add ‘ExecuteSQLCommand’ event to the button.
Select a SQL connection in the Connection property. In the CommandDetails property, choose the Stored Procedure you want to connect to. Click on Refresh Parameters button. Parameters that are in the Stored Procedure are added automatically in Stadium.
Input parameter settings :
Assign the DetailsView field value to the Input Parameters (value and exchangeValue) using ‘Control’ Parameter Source.
Set Parameter source for Output Parameter (calculatedValue) to ‘Output to Variable’. Select the output variable from OutputToVariable dropdown list. Type value can be selected from Boolean, DateTime, Int and String depending on the type of data you want to display.
Add SetControlProperties event after the ExecuteSQLCommand event. SetControlProperties event can be used to assign the variable value to other controls. In this example, we will be assigning it to a Label control.
Check on the Label. Select the variable that is used to store the output values (calculateVariable) as Text value.
Other Controls that can display values from Variables are :
- DetailsView
- DataGrid
- TextBox
In summary, users can call a Stored Procedure, pass values to the Input Parameters and display results received from the Output parameter.
- A Stadium control passes input values to Stored Procedure
- Stored Procedure does the Calculation, then passes the result to a Stadium control
- Stadium Control saves the results to a variable to be used when needed.
No comments:
Post a Comment