Answered by:
Passing new parameters to Report(.rdlc)

Question
-
Hi guys, ive sucessfully made a simple report(.rdlc) in VB.Net using the "wizard" of Visual Team Suite.
Now, is there anyone here who could help me pass a new parameter to the report?
For example, i have a report that shows ALL the transaction of a company. Now, what need I need to know is how will I pass a new parameter to the report if the user only wants to view certain data like data from a Jan. 1, 2006 to Jan. 5, 2006?Wednesday, September 6, 2006 7:00 AM
Answers
-
The folks in the Visual Studio Report Controls forum (http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=75&SiteID=1) may be able to help more.
From http://forums.microsoft.com/MSDN/ShowPost.aspx?PageIndex=2&SiteID=1&PostID=676697
Passing a parameter to a report:
Dim RateId as integer = 5
Dim params(0) As ReportParameter
params(0) = New ReportParameter("RateId", RateId, False)
Me.ReportViewer1.ServerReport.SetParameters(params)
Me.ReportViewer1.ServerReport.Refresh()
Wednesday, September 6, 2006 5:27 PM
All replies
-
The folks in the Visual Studio Report Controls forum (http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=75&SiteID=1) may be able to help more.
From http://forums.microsoft.com/MSDN/ShowPost.aspx?PageIndex=2&SiteID=1&PostID=676697
Passing a parameter to a report:
Dim RateId as integer = 5
Dim params(0) As ReportParameter
params(0) = New ReportParameter("RateId", RateId, False)
Me.ReportViewer1.ServerReport.SetParameters(params)
Me.ReportViewer1.ServerReport.Refresh()
Wednesday, September 6, 2006 5:27 PM -
Hi friend,
I used ur above defined code to pass parementers to my Report Viewer object, Initially it shows all records and I add a Refresh button to add the given code but I m having an Error "An error occurred during local report processing." and my Application crashes on pressing the refresh button my code is as follows
params(0) =
New ReportParameter("MessageTemplateID", MessageTemplateID, False) Me.ReportViewer1.LocalReport.SetParameters(params) '<<<<>>>>>>>>>>>> Appplivcation crashes at this point Me.ReportViewer1.RefreshReport()please help ASAP...
Thursday, May 24, 2007 2:03 PM -
I just came across your posting from several months ago. You've probably figured it out by now, but just in case...
First, the error you mentioned, "An error occurred during local report processing.", is just a general "wrapper" message. To see what really went wrong, you have to drill down and look at the InnerException. My guess is that your parameter was not defined in the report itself.
So, after you've added that VB code to the code-behind, you also need to define the parameter in the .rdlc file as well. With the .rdlc file open in Visual Studio, go to the Report menu and select Report Parameters...
To be consistent with the above VB code, add a parameter named MessageTemplateID of type Integer and then click OK to close the window.
In your .rdlc report designer, you can now add a textbox and use the Expression editor (right-click the textbox and select expression...) to set its value =Parameters!MessageTemplateID.Value.
When you run the report, the textbox should contain the value, 5.
Good luck.
- Proposed as answer by balaji_bala Sunday, December 7, 2008 9:11 PM
Friday, October 5, 2007 11:57 PM -
Dear Scott Cook,
Thankyou very much, Yes u r right I have figured it out but ur explanation are very helpful in understanding the Report(.rdlc)
Thank U again
Saturday, October 6, 2007 7:42 AM -
Hi Nabeel,
I struggling to solve this parameter issue for last few weeks. It would be really nice if you can help me on how to call parameters on reportviewer, so that i can have date range. I really expend a lot of time on this but without success.
From the above discussion I found below code helped you out to solve this problem. But not sure exactly in which even I need to write this code:
Dim MessageTemplateID As Integer = 5
Dim params(0) As ReportParameter
params(0) = New ReportParameter("MessageTemplateID", MessageTemplateID, False)
Me.ReportViewer1.LocalReport.SetParameters(params) '<<<<>>>>>>>>>>>> Appplivcation crashes at this point
Me.ReportViewer1.RefreshReport()
I would be really thankful to you if can provide me a sample of your coding in the code behind...
Thanks a lot in advance..
Regards,
Emam
Thursday, October 11, 2007 1:32 AM -
Dear MEmam
First of all U have to create a parameter in the report then call it in ur report.
Please show me what U r doing and what U want to do..
U can call parameters in different events according ur need. it can be called on Page Load, Button Click and on Datetime box date change events.
U have to make a Parameter array (even if U wanna add a single parameter) and also add these parameter(s) in the rdlc report.
Friend I actually avoided parameters that time and used dataset behind my reports
Thursday, October 11, 2007 7:14 AM -
Dear Nabeel,
Thanks for your reply.
Actually what I want to do is just generating a report passing some parameter value at run time. It's like a date range by passing @startdate and @enddate. But i can do this only by using SQL server reporting
services (.rdl), but not by Reportviewer (.rdlc). At the moment I don't have any code to give you as I just have .aspx page and a reportviewer on it, which generate the report in local mode.
I just need a sample of how exactly I would be able to pass parameters on reportviewer as like @startdate and @enddate when you do by reporting services(.rdl, which pops up two text box to accept values for startdate and enddate).
Actually I have never done this before. It would be really nice if you have some more information or links.
OR
Also, if anyone else has any good links on this issue, are most welcome.
Thanks
Emam
Wednesday, October 17, 2007 11:43 PM -
Hi,
Can you help me with a website about creating Crystal or Normal reports in VB.NET.
Wednesday, August 13, 2008 6:15 PM -
The source of the report definition has not been specified body {font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;} p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px} b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px} H1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red } H2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon } pre {font-family:"Lucida Console";font-size: .9em} .marker {font-weight: bold; color: black;text-decoration: none;} .version {color: gray;} .error {margin-bottom: 10px;} .expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:hand; }i got this error ........
The source of the report definition has not been specified
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: Microsoft.Reporting.WebForms.MissingReportSourceException: The source of the report definition has not been specified
Source Error:
Line 22: params(0) = New ReportParameter("a", DropDownList1.SelectedItem.Text, False) Line 23: Line 24: Me.ReportViewer1.ServerReport.SetParameters(params) Line 25: Line 26: Me.ReportViewer1.ServerReport.Refresh()
balajiSunday, December 7, 2008 9:10 PM -
The source of the report definition has not been specified body {font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;} p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px} b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px} H1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red } H2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon } pre {font-family:"Lucida Console";font-size: .9em} .marker {font-weight: bold; color: black;text-decoration: none;} .version {color: gray;} .error {margin-bottom: 10px;} .expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:hand; }The source of the report definition has not been specified
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: Microsoft.Reporting.WebForms.MissingReportSourceException: The source of the report definition has not been specified
Source Error:
Line 22: params(0) = New ReportParameter("a", DropDownList1.SelectedItem.Text, False) Line 23: Line 24: Me.ReportViewer1.ServerReport.SetParameters(params) Line 25: Line 26: Me.ReportViewer1.ServerReport.Refresh()
balajiSunday, December 7, 2008 9:12 PM -
This works excellent.
Thanks.Friday, August 21, 2009 12:57 AM -
Worked for me tooSunday, February 20, 2011 1:45 AM
-
Hi i am using the report wizard in vstudio 2008 for generating a report. it is working fine.but my issue is while i run the application the application must prompt me for user input and use that input in generating a report. How can i achieve that? Any one passed through this situation?
Thanks in advance,
KRISHNA.
Wednesday, March 14, 2012 9:52 AM -
it worked very well and the error solved . I didn't set report source for my reportviewer control , i just simply selected the reportviewer and clicked on little arrow at the top of that control and choose my report to show and the error solved .
thanks .
Saturday, September 28, 2013 4:39 AM -
it worked very well and the error solved . I didn't set report source for my reportviewer control , i just simply selected the reportviewer and clicked on little arrow at the top of that control and choose my report to show and the error solved .
thanks .
Saturday, September 28, 2013 4:39 AM