PassQueryParametersToReport

Stimulsoft Reports.WEB discussion
Post Reply
JohnW
Posts: 103
Joined: Mon Nov 20, 2017 8:29 pm

PassQueryParametersToReport

Post 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.
Lech Kulikowski
Posts: 6238
Joined: Tue Mar 20, 2018 5:34 am

Re: PassQueryParametersToReport

Post 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.
JohnW
Posts: 103
Joined: Mon Nov 20, 2017 8:29 pm

Re: PassQueryParametersToReport

Post 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.
JohnW
Posts: 103
Joined: Mon Nov 20, 2017 8:29 pm

Re: PassQueryParametersToReport

Post 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
Lech Kulikowski
Posts: 6238
Joined: Tue Mar 20, 2018 5:34 am

Re: PassQueryParametersToReport

Post by Lech Kulikowski »

Hello,

Please check the following sample:
https://www.stimulsoft.com/en/samples/r ... es-in-code

Thank you.
JohnW
Posts: 103
Joined: Mon Nov 20, 2017 8:29 pm

Re: PassQueryParametersToReport

Post 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
JohnW
Posts: 103
Joined: Mon Nov 20, 2017 8:29 pm

Re: Resolved PassQueryParametersToReport

Post by JohnW »

I found the syntax.

I needed to use the Dictionary object.

report.Dictionary.Variables("varApplicationID").Value = 3
Max Shamanov
Posts: 786
Joined: Tue Sep 07, 2021 10:11 am

Re: PassQueryParametersToReport

Post by Max Shamanov »

Hello,

Ok.
Let us know if you need our help.

Thank you.
Post Reply