passing variables to the report
Hi I'm trying to pass a variable to my report, I have a report with one adoquery and I have this script for on the start report.
ADOquery1.active:=false;
ADOquery1.sql[6]:='where g.per_pk='''+<periodo>+''';
ADOquery1.active:=true;
in the fastr report 3 VCL I use this line
dmprincipal.frxReport1.Script.Variables:=Periodopk.Value;
from my Delphi code.
How can i Do this trought my VB.Net code.
thanks.
ADOquery1.active:=false;
ADOquery1.sql[6]:='where g.per_pk='''+<periodo>+''';
ADOquery1.active:=true;
in the fastr report 3 VCL I use this line
dmprincipal.frxReport1.Script.Variables:=Periodopk.Value;
from my Delphi code.
How can i Do this trought my VB.Net code.
thanks.
Comments
These days FastReport Studio supports SQL parameters. For example, you can write following query:
SELECT e.*
FROM
employee e
WHERE
e.Salary >:salary_limit
In this case salary_limit is a VARIABLE, that transmitted into query. Below is VB6 snippet, that control the SQL parameter:
Private Sub Command1_Click()
Dim Query As FastReport.TfrxADOQuery
Dim Param As FastReport.IfrxParamItem
Set Query = report.FindObjectEx("ADOQuery1")
If Query Is Nothing Then Return
Set Param = Query.ParamByName("salary_limit")
If Param Is Nothing Then Return
Param.Expression = Text1.Text
Set Param = Nothing
report.ShowReport
Set Query = Nothing
End Sub
Sorry, I have no VB.NET example right now.
Setting a variable's value within FastScript namespace is not more difficult than in FR Delphi:
dmprincipal.frxReport1.Script.Variables["periodo"]:=Periodopk.Value;
S you can see, this code almost same to Delphi code, except double quotes instead of single quotes.