Answered Passing new parameters to Report(.rdlc)

  • Wednesday, September 06, 2006 7:00 AM
     
     
    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?






All Replies

  • Wednesday, September 06, 2006 5:27 PM
     
     Answered

    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()

  • Thursday, May 24, 2007 2:03 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

     

    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()

     

    please help ASAP...

  • Friday, October 05, 2007 11:57 PM
     
     Proposed Answer

    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 07, 2008 9:11 PM
    •  
  • Saturday, October 06, 2007 7:42 AM
     
     

    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 Smile

  • Thursday, October 11, 2007 1:32 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 7:14 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 Wink

  • Wednesday, October 17, 2007 11:43 PM
     
     

    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, August 13, 2008 6:15 PM
     
     
    Hi,

    Can you help me with a website about creating Crystal or Normal reports in VB.NET.
  • Sunday, December 07, 2008 9:10 PM
     
      Has Code
    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()

    balaji
  • Sunday, December 07, 2008 9:12 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()

    balaji
  • Friday, August 21, 2009 12:57 AM
     
     
    This works excellent.
    Thanks.
  • Sunday, February 20, 2011 1:45 AM
     
     
    Worked for me too
  • Wednesday, March 14, 2012 9:52 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.