none
VS2013 IDE error An attempt was made to set a report parameter 'mydate1' that is not defined in this report." RRS feed

  • Question

  • Hello Community

        In and earlier version of VS IDE when you created an rdlc on the Toolbar there was a selection named "Report" where you were allowed to enter the name and type of a report parameter you were passing from a report form containing a ReportViewer control.

        I am using VS 2013 IDE so the problem I am having is that when the form containing the ReportViewer control calls the rdlc, the codebehind fails during the parameters code in the codebehind as such:

                ReportParameter[] myparms = new ReportParameter[2];
                parm1[0] = new ReportParameter("mydate1", fromDate.ToString());
                parm2[1] = new ReportParameter("mydate2", toDate.ToString());
                this.reportViewer1.LocalReport.SetParameters(myparms);
                this.reportViewer1.RefreshReport();

        The actual line that fails is: this.reportViewer1.LocalReport.SetParameters(myparms); and the error says:

    Exception:Thrown: "An attempt was made to set a report parameter 'mydate1' that is not defined in this report." (Microsoft.ReportingServices.Diagnostics.Utilities.UnknownReportParameterException)

        My questions are:
           
            1) In VS2013 IDE how do you create an rdlc that will be called by a form that has a ReportViewer control and will be passing a parameter?

            2) What does the error mean when it says an"attempt" was made to set a report parameter mydate1 that is not defined in this report (the code shown is the same way I coded the codebehind in earlier versions and those reports worked the only difference was that I dragged a TableAdapter on the form containing the ReportViewer and in vs2013 I am using a dataset as the datasource)?

         Thanks
         Shabeaut

    • Moved by Kristin Xie Thursday, March 10, 2016 7:46 AM Report viewer related
    Wednesday, March 9, 2016 2:53 PM

Answers

  • Hello Community

        All you have to do is add the parameter to the dataset and rdlc.

        Shabeaut

    • Marked as answer by Shabeaut Tuesday, March 15, 2016 9:02 PM
    Tuesday, March 15, 2016 9:02 PM

All replies

  • The error is saying that you are trying to pass a parameter called mydate1 to the RDLC but the report doesn't have such a parameter. Open the RDLC in the designer, go to the Parameters section and verify the parameter exists. Note that case may matter.

    Michael Taylor
    http://www.michaeltaylorp3.net

    Wednesday, March 9, 2016 3:11 PM
  • Hello Michael Taylor

       Let me rephrase the question, in VS2013 in the rdlc, if you go to a textbox, highlight and right click the field name then choose Expression you see in the list the word "Parameters" but when clicked on
    it says "Report has no parameters".

        So how to you resolve the problem that the rdlc says "Report has no parameters"?

        Thanks
        Shabeaut

    Wednesday, March 9, 2016 7:24 PM
  • Open the report in the designer. Then go the Report Data view (View\Report Data).  The report parameters are listed under Parameters.  You can add new parameters here which make them accessible when setting up the report and when building the report request.
    Wednesday, March 9, 2016 7:41 PM
  • I have written "tens" of reports in VS2008 but I can't figure out VS2013 reports.

    For example:

    In the "Date" field I inserted the following code in its "Expression"

    =(Fields!Date.Value >= Parameters!FromDate.Value And Fields!Date.Value <= Parameters!ToDate.Value)

      Instead of returning all rows where the "Date" field is greater than or equal to the "From Date" parameter that gets passed to the rdlc and "Date" field is less than or equal the "ToDate"  parameter that  gets passed to the rdlc, "all rows" are returned and the "Date" field column in the report contains the word "False" in each row.

        What am I doing wrong?





    • Edited by Shabeaut Wednesday, March 9, 2016 8:56 PM
    Wednesday, March 9, 2016 7:53 PM
  • You're changing your question from the original topic of rendering a report to defining a report. You should really create a new question for this.  It isn't related to C# and should go in the reporting forums.

    But to get you started, once you've defined your parameter and set your expressions you should be able to go to the Preview tab and render the report.  If the parameters show up at the top of the report then they are defined properly. If you get any rendering errors then you have something wrong with your expressions and the designer will clarify what.

    Once you've gotten your report rendering properly then your original question of how to set the parameters outside the report should be correct. But the caveat is that you appear to be defining your report parameters as DateTime but in your original code you were passing in strings. You should pass DateTime values if that is what the parameters are.

    Wednesday, March 9, 2016 8:22 PM
  • Hello Community

        All you have to do is add the parameter to the dataset and rdlc.

        Shabeaut

    • Marked as answer by Shabeaut Tuesday, March 15, 2016 9:02 PM
    Tuesday, March 15, 2016 9:02 PM