sending parameters from windows application to the report

Stimulsoft Reports.NET discussion
Post Reply
imax36581
Posts: 12
Joined: Sat Aug 29, 2009 6:22 am
Location: teh

sending parameters from windows application to the report

Post by imax36581 »

Hi
currently i designed a report with embedded parameters that work well for me.
but i want to know that is there any way to send the parameters value to the report from my windows application?
i see a video about this but in web application,i think its a little bit different in windows application.so how can i do this?
my second question is about generating the report for the second time,in a simple button i write a "strireport1.show();" code,so i can view my report,but when i try to see my report for the second time,it does not present me my form,just a blank page!.
Thanks in Advance
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

sending parameters from windows application to the report

Post by Edward »

Hi
imax36581 wrote:Hi
currently i designed a report with embedded parameters that work well for me.
but i want to know that is there any way to send the parameters value to the report from my windows application?
i see a video about this but in web application,i think its a little bit different in windows application.so how can i do this?
The method of passing parameters is the same. Here you are.

In the most cases you can use the following simple steps to pass parameters into the report:

1. Declare a parameter in the DataSource with the following name, for example:
@MyParameter

2. After compilation of the report:
report.Compile()

3. you can assign that parameter as follows:
report["@MyParameter"] = 5;

Here are the links on how to use named and unnamed parameters:
Named parameters:
http://www.stimulsoft.com/livedemos/Rep ... eters.html

Unnamed parameters:
http://www.stimulsoft.com/livedemos/Rep ... ers_2.html

There is another method of sending parameters using of the report variable. This method is suitable in case if non of named (@myparameter) or
unnamed (?) parameters worked as it was discussed here:
http://forum.stimulsoft.com/Default.aspx?g=posts&t=504

How to send parameters for SQL query by application?

1. You can use an expression to form any part in SQL query. First, you add variables to the SQL query:
select * from customers where code = {myvariable}

2. You need to create a variable in the Report Dictionary.

3. You need to initialize a variable before report running:

C#
StiReport report = new StiReport();
report.Load("Variables.mrt");
report.Compile();

//Set Variable
report["myvariable"] = 123;
report.Render();

VB
Dim Report As StiReport = New StiReport()
Report.Load("Variables.mrt")
Report.Compile()

'Set Variable
report.Item("myvariable") = " Value "
Report.Render()

Also please open Demo.exe sample application from the standard installation of Stimulsoft Reports.Net.

Open 'SQL' category and the report Master-Detail with Parameters. Press 'Design' button. It is another example of using parameters.

And in Program Files\Stimulsoft Reports.Ultimate 2009.3 Trial\Samples\WinForms\C#\SqlParameters\ you can find a project which describes work with parameters in Stimulsoft Reports.Net.

Additional documentation you can find here:
http://stimulsoft.com/Documentation.aspx

Also we have some other video tutorials:
http://stimulsoft.com/ReportsNetVideos.aspx
my second question is about generating the report for the second time,in a simple button i write a "strireport1.show();" code,so i can view my report,but when i try to see my report for the second time,it does not present me my form,just a blank page!.
Thanks in Advance
Please call the following method to reset rendering state of the report before launching Show() method:

stiReport1.ResetRenderedState();

Thank you.
imax36581
Posts: 12
Joined: Sat Aug 29, 2009 6:22 am
Location: teh

sending parameters from windows application to the report

Post by imax36581 »

thanks,but...
my code is like this:
StiReport report = new StiReport();
report.Load(".//Reports//Report_eghamat.mrt");
report.Compile();
report["@mahal"] = ComboBox1.Text;
report.Render();
report.Show();

but when it showes my report its empty,just i see my report header :( .
it seems that the parameter don't send to my report correctly.
Thanks in advance
imax36581
Posts: 12
Joined: Sat Aug 29, 2009 6:22 am
Location: teh

sending parameters from windows application to the report

Post by imax36581 »

thanks,but...
my code is like this:
StiReport report = new StiReport();
report.Load(".//Reports//Report_eghamat.mrt");
report.Compile();
report["@mahal"] = ComboBox1.Text;
report.Render();
report.Show();

but when it showes my report its empty,just i see my report header :( .
it seems that the parameter don't send to my report correctly.
Thanks in advance
Jan
Posts: 1265
Joined: Thu Feb 19, 2009 8:19 am

sending parameters from windows application to the report

Post by Jan »

Hello,

Please check attached sample project.

Thank you.
Attachments
317.SqlParameters.zip
(39.83 KiB) Downloaded 1065 times
imax36581
Posts: 12
Joined: Sat Aug 29, 2009 6:22 am
Location: teh

sending parameters from windows application to the report

Post by imax36581 »

Thank you.
i found my mistake .
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

sending parameters from windows application to the report

Post by Edward »

Hi

Please let us know if any help is required.

Thank you.
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: sending parameters from windows application to the repor

Post by Alex K. »

Hello,

Please try to use the following code:

Code: Select all

report.Dictionary.DataSources["DataSourceName"].Parameters["ParameterName"].Value = value; 
Post Reply