ComponentOne True DataControl 8.0
Parameters in Expressions

You can use parameters in any True DataControl expression to implement dependencies on values that change dynamically at run time. When you use a parameter for this purpose, leave its SQLParameter property empty, use the parameter name in the expression where you need it, and set the parameter in code when you need its value changed. See Accessing parameter values in code for details. Alternatively, you can specify the parameter’s ValueExpression, then it will be evaluated automatically.

If you set the parameter value in code, True DataControl will re-evaluate expressions that depend on that parameter. True DataControl will refresh its recordset if necessary, that is, if this type of expression forces refresh on its asynchronous evaluation. For more information, see Expression Evaluation Rules.

A special case of setting a parameter value is in the WillOpenData event, where it will not cause expression re-evaluations and refresh. When you set a parameter value in WillOpenData, it just becomes the value of that parameter, provided ValueExpression is not specified. This way you can define a default value for a parameter, to be assigned when the TData control is loaded.

An alternative way to give your parameter a default value is to specify its ValueExpression. However, you must bear in mind that if ValueExpression is non-empty, it will be used to evaluate the parameter value on every refresh.

Example:

Suppose you want to impose a range condition on the LastName fields, so your recordset contains only those records that are equal to a specified value. And you need to set this value in code.

This can be done by creating a parameter (Param1), creating a range condition for the field, and specifying Param1 as the ValueExpression for that range condition.

When you set:

Example Title
Copy Code
TData1.Parameters(“Param1”) = “Bach”

TData will refresh its recordset, fetching only those records where LastName = ”Bach” because the ValueExpression forces refresh on asynchronous evaluation. For more information, see Expression Evaluation Rules.

If you want to set the parameter to “Beethoven” at startup, you can do so in the WillOpenData event:

Example Title
Copy Code
Private Sub TData1_WillOpenData()

TData1.Parameters(“Param1”) = “Beethoven”

End Sub

 

 


Copyright (c) GrapeCity, inc. All rights reserved.

Product Support Forum  |  Documentation Feedback