Page 1 of 1
PassQueryParametersToReport
Posted: Fri Dec 30, 2022 3:36 pm
by JohnW
I would like to pass a value to a report to pull the data based on the value.
For example, I have an ApplicationID an Integer that = 3 . I would like to pass that value to the report to see the information for the ApplicationID that equals 3.
I would like to do that in code, I cannot seem to find and example. I see the function 'PassQueryParametersToReport' but I am not sure of the syntax or where to use it?
Can someone give me an example or point me to the information that explains it.
I am using the current version of Stimulsoft and program in VB.net.
Re: PassQueryParametersToReport
Posted: Fri Dec 30, 2022 5:34 pm
by Lech Kulikowski
Hello,
How do you register data in the report? Is it DataSet or database connection with queries?
You can use variables as parameters in the query or in Filters of the DataBand.
Please check the Parameters category on the Demo:
https://demo.stimulsoft.com/#Net/Parame ... Categories
Thank you.
Re: PassQueryParametersToReport
Posted: Fri Dec 30, 2022 7:14 pm
by JohnW
I am using a data query with a where statement 'where applicationID = @ApplicationID.
When I test the query in the report designer it works fine. I need to move it to a web app and pass the value from a Session variable if possible, failing that Query parameter.
I will look at the link.
Re: PassQueryParametersToReport
Posted: Fri Dec 30, 2022 7:58 pm
by JohnW
Thi is the code I am trying to get to run on the code behind page.
Code: Select all
Protected Sub StiWebViewer1_GetReport(ByVal sender As Object, ByVal e As StiReportDataEventArgs)
Dim report = StiReport.CreateNewReport()
Dim path = Server.MapPath("Reports/OnlineApp.mrt")
report.Load(path)
e.Report = report
e.Report.Variables.Item("@ApplicationID") = 3
End Sub
Re: PassQueryParametersToReport
Posted: Sat Dec 31, 2022 10:23 am
by Lech Kulikowski
Re: PassQueryParametersToReport
Posted: Sat Dec 31, 2022 3:35 pm
by JohnW
I understand how to create a variable. What I don't understand is what stimulsoft object/property is used to receive it for the report to make use of it when it renders.
It is more of a namespace,object, property question.
I hope this added information is useful in narrowing things down.
John W
Re: Resolved PassQueryParametersToReport
Posted: Sat Dec 31, 2022 4:04 pm
by JohnW
I found the syntax.
I needed to use the Dictionary object.
report.Dictionary.Variables("varApplicationID").Value = 3
Re: PassQueryParametersToReport
Posted: Tue Jan 03, 2023 7:31 am
by Max Shamanov
Hello,
Ok.
Let us know if you need our help.
Thank you.