SSRS 2008: error message saying my parameter doesn't exist but it clearly does?
Asked Answered
D

12

30

I have a report that has about 10 parameters and about 10 datasets and one datasource. I typed alot but I really need help so I figured I would try and provide as much info about the problem as I could right from the start.

Let's simplify it all and pretend these are the relevant names of everything and that the report gets basic employee information:

  • Parameters
    • facilityID: text in the format of a guid or uniqueidentifier, this is hidden and passed in so that the end user of the report can only view info for their own facility; Single valued parameter, not blank not null, hidden, text
    • startDate: start date range, let's say I want my report to include data starting Jan 1 this year; Single valued parameter, not blank not null, visible, datetime
    • endDate: end of the date range, let's say it's today/now; Single valued parameter, not blank not null, visible, datetime
    • viewOption: three hard-coded values (label, value) ("Current Employees",1) and ("Past Employees",2) and ("Employees that moved facilities",3); Multi-valued Parameter (so select all is an option), not blank, not null, visible, text
    • personID: based on the dataset getListOfNames where the label is the employee name and the value is their personID (guid/uniqueidentifier); Single select, not null, not blank, text and visible
  • My Data Sets
    • getListOfNames: this gets a list of people that were at the company in the provided date range at the given facility and where their employee status is in the viewOption parameter value (so it can be just one number or up to three). This is a stored procedure but I have set up it to handle the multi-valued parameter by passing it join(parameter, "~") and then separating it out in the stored proc. This works on 5 other reports.
    • getReportInfoOnSelectedPerson: main body query; after the user selects the employee they want data on, this takes that personID and the date range and fills the main table.

The problem:
SSRS says viewOption doesn't exist. But I see it, right there, in the Parameters folder on the left hand side. I see it when I go to enter an expression under Parameters. There is no squiggly red line under Parameters!viewOption.value. But, when I try and put it as a value for a parameter used by the getListOfNames dataset, it errors. If I put it in the getReportInfoOnSelectedPerson dataset and use it in the exact same way, SSRS is okay with that. Wtf? So... I have checked the rdl and everything is fine (where the actual parameter is declared, where it is used in the dataset reference, everything). It's just this one dataset. And I have a similar report that uses the same data set, same basic parameters and that report is fine. I try setting the value of the dataset parameter to 1 or something and that is fine but when I try and set it to Parameter!viewOption.value it errors..... Now, above I said i normally pass the stored proc a Join on the paramater with a tilde ~ but I am trying to keep it simple and either get it to just work in general (either by passing it the first value of the multivalue viewOption parameter or turning that parameter into a single select and just passing the .value) but the join doesnt work either. All of those things work for the other dataset, which is also a stored proc.

This is my error:
An error has occurred during report processing. (rsProcessingAborted) The Value expression for the query parameter ‘@viewOption’ contains an error: The expression referenced a non-existing parameter in the report parameters collection. (rsRuntimeErrorInExpression)

Which is clearly saying my parameter doesn't exist but I can SEE it... everywhere. And if I assign one of the other datasets' parameter values to the viewOption parameter it works without an error. I've checked the rdl.

I've had this problem before and it was fixed by deleting both the parameter and dataset and creating them again (for safety I renamed both of them). That didn't work this time.

I am so frustrated. Please help....

Code?

      <DataSet Name="getListOfNames">
      <Fields>
          <Field Name="personID">
              <DataField>PersonId</DataField>
              <rd:TypeName>System.Guid</rd:TypeName>
          </Field>
          <Field Name="name">
              <DataField>name</DataField>
              <rd:TypeName>System.String</rd:TypeName>
          </Field>
      </Fields>
      <Query>
          <DataSourceName>myDataSource</DataSourceName>
          <CommandType>StoredProcedure</CommandType>
          <CommandText>getListOfNames</CommandText>
          <QueryParameters>
              <QueryParameter Name="@fac">
                  <Value>=join(Parameters!fac.Value,"~")</Value>
              </QueryParameter>
              <QueryParameter Name="@bldg">
                  <Value>=join(Parameters!bldg.Value,"~")</Value>
              </QueryParameter>
              <QueryParameter Name="@unit">
                  <Value>=join(Parameters!unit.Value,"~")</Value>
              </QueryParameter>
              <QueryParameter Name="@station">
                  <Value>=join(Parameters!station.Value,"~")</Value>
              </QueryParameter>
              <QueryParameter Name="@startDate">
                  <Value>=Parameters!startDate.Value</Value>
              </QueryParameter>
              <QueryParameter Name="@endDate">
                  <Value>=Parameters!endDate.Value</Value>
              </QueryParameter>
              <QueryParameter Name="@viewOption">
                  <Value>=Join(Parameters!viewOption.Value, "~")</Value>
              </QueryParameter>
          </QueryParameters>
          <rd:UseGenericDesigner>true</rd:UseGenericDesigner>
      </Query>
  </DataSet>



<ReportParameter Name="viewOption">
  <DataType>String</DataType>
  <DefaultValue>
    <Values>
      <Value>1</Value>
    </Values>
  </DefaultValue>
  <Prompt>View</Prompt>
  <ValidValues>
    <DataSetReference>
      <DataSetName>viewOptionQuery</DataSetName>
      <ValueField>value</ValueField>
      <LabelField>label</LabelField>
    </DataSetReference>
  </ValidValues>
  <MultiValue>true</MultiValue>
</ReportParameter>



<DataSet Name="viewOptionQuery">
  <Fields>
    <Field Name="label">
      <DataField>label</DataField>
      <rd:TypeName>System.String</rd:TypeName>
    </Field>
    <Field Name="value">
      <DataField>value</DataField>
      <rd:TypeName>System.Int32</rd:TypeName>
    </Field>
  </Fields>
  <Query>
    <DataSourceName>flamingo</DataSourceName>
    <CommandText>select 'Other Facility' as label, 3 as value union select 'Past' as label, 2 as value union select 'Current' as label, 1 as value order by value</CommandText>
    <rd:UseGenericDesigner>true</rd:UseGenericDesigner>
  </Query>
</DataSet>

This is how it is set up and getListOfNames is why the error is throw, if I change

              <QueryParameter Name="@viewOption">
                  <Value>=Join(Parameters!viewOption.Value, "~")</Value>
              </QueryParameter>

to

              <QueryParameter Name="@viewOption">
                  <Value>="1~2"</Value>
              </QueryParameter>

then it works.... or the value can be just 1 or 1~2~3

However... when I try and put join(Parameters!viewOption.value,"~") as the value for another dataset's query parameter it works and there is no error.

  <DataSet Name="getReportInfoOnSelectedPerson">
  <Fields>
    <Field Name="name">
      <DataField>name</DataField>
      <rd:TypeName>System.String</rd:TypeName>
    </Field> 
    <Field Name="Building">
      <DataField>Building</DataField>
      <rd:TypeName>System.String</rd:TypeName>
    </Field>
    <Field Name="Unit">
      <DataField>Unit</DataField>
      <rd:TypeName>System.String</rd:TypeName>
    </Field>
    <Field Name="desc">
      <DataField>desc</DataField>
      <rd:TypeName>System.String</rd:TypeName>
    </Field> 
  </Fields>
  <Query>
    <DataSourceName>myDataSource</DataSourceName>
    <CommandType>StoredProcedure</CommandType>
    <CommandText>Reports_BasicInfo</CommandText>
    <QueryParameters>
      <QueryParameter Name="@personID">
        <Value>=Parameters!personID.Value</Value>
      </QueryParameter>
      <QueryParameter Name="@numberINeedToAggregateData">
        <Value>=Join(Parameters!viewOption.Value,"~")</Value>
        <rd:UserDefined>true</rd:UserDefined>
      </QueryParameter>
    </QueryParameters>
    <rd:UseGenericDesigner>true</rd:UseGenericDesigner>
  </Query>
</DataSet>

And I already said this, but the stored proc/dataset that throws the error uses a parameter with the same set up in about 5 other reports (I have tried copying and pasting the relevant code sections from working reports but I still get the error). So, what's wrong with this one?

Dorrisdorry answered 9/3, 2011 at 21:47 Comment(2)
I know you said you've tried this before, but I've had similiar issues in reporting services. I had to try from scratch and it seemed to work, seems to be buggy at times. Also always run your sproc from SQL Server to see if they work before bringing over to RS. Finally, when you add additional parameters at a later date for some reason the behind code of the report doesn't get updated and you have to manually type in the code..very buggy. +1 though for in depth details.Inexpedient
I just posted something as an "answer" to this... The report was way too detailed and complex to just start over so I just copied the code and that seemed to work. I would really like to know why this happened, though. I always make sure the stored proc's work and I re-use some of them... I've also learned to always check the code behind SSRS, too.Dorrisdorry
P
25

I found in my situation that it was actually the parameters name casing was slightly changed and it was throwing this same error.

I had to change the name to the correct casing, and then search in the code behind to anything that refers to that parameter and correct its casing. Deployed fine after that.

Paranoia answered 6/11, 2012 at 23:4 Comment(3)
this is an old question and i don't work with this stuff anymore... but thank's for the reply. SSRS is a funny thing; not sure if it got any better. ultimately, i went into the actual sql server database behind all of the reporting and dug out some solution. you're definitely right, though, it had something to do with something being case sensitive. it would display to me, the user, completely the same but somewhere in the DB it was different. i'll give you the answer to this question b/c it's better late than never. thanks!Dorrisdorry
Point of clarification here - it's code which is only visible in the xml that has the casing problem. To fix it, you have View Code and then find it and fix it. Very obnoxious.Aretina
That's SSRS for you! A senior lead explained to me why. If you have to have a situation that runs an automated job, everything has to be spot on accurate! Any minor change and it will fail.Paranoia
S
32

Try changing the order of the parameters using the up/down arrows.

They should appear in the order of dependence.

Sagesagebrush answered 12/6, 2012 at 23:36 Comment(1)
This solved a problem I was having as well. If two datasets need the same parameter, and one of them depends on the output of the other, the common parameter has to be listed at the top of the list.Ry
P
25

I found in my situation that it was actually the parameters name casing was slightly changed and it was throwing this same error.

I had to change the name to the correct casing, and then search in the code behind to anything that refers to that parameter and correct its casing. Deployed fine after that.

Paranoia answered 6/11, 2012 at 23:4 Comment(3)
this is an old question and i don't work with this stuff anymore... but thank's for the reply. SSRS is a funny thing; not sure if it got any better. ultimately, i went into the actual sql server database behind all of the reporting and dug out some solution. you're definitely right, though, it had something to do with something being case sensitive. it would display to me, the user, completely the same but somewhere in the DB it was different. i'll give you the answer to this question b/c it's better late than never. thanks!Dorrisdorry
Point of clarification here - it's code which is only visible in the xml that has the casing problem. To fix it, you have View Code and then find it and fix it. Very obnoxious.Aretina
That's SSRS for you! A senior lead explained to me why. If you have to have a situation that runs an automated job, everything has to be spot on accurate! Any minor change and it will fail.Paranoia
D
10

Re-ordering the report parameters based on their dependency fixed the issue for me. I had the report parameter at the bottom of the list but the one above it was dependent on this bottom one. So when you are creating / re-creating the report parameter make sure the order is right.

Devaney answered 3/9, 2013 at 21:13 Comment(1)
This solved my problem, thanks! But WHY!! I can now see that in the Report Data pane, if you select a parameter two small arrows is enabled in the top tool bar of the pane. Here you can move parameter up and down to order them.Yeager
G
8

This could mostly be due to the parameter name not being updated in the dataset.

This article helped me resolve it

When editing Parameters (names or case) for a Dataset within SSRS you may encouter the previous error message when you preview the report. While on the surface it may appear that the parameter has the same case in the Parameter settings and the Dataset query – there is another place where a change is required.

  1. Open the Dataset properties for the Dataset (s) that use the Parameter in the error message.
  2. Select the Parameters property in the left list pane.
  3. Click the Expression Editor button for the specified Parameter.

enter image description here

  1. Here you will notice that the Expression is underlined in red. This is where you will need to correct the case of the Parameter name.

    enter image description here

Gaylenegayler answered 28/2, 2017 at 9:22 Comment(0)
H
7

Had the same problem. Check the Parameters tab of the Dataset Properties and click the expression (fx) button. The parameters don't seem to refresh automatically here, one of my parameters still had uppercase instead of lowercase spelling

Henceforth answered 23/1, 2014 at 11:16 Comment(0)
A
3

The problem also occurs if you reference a parameter "too early", e.g. from within an overriden OnInit. In that case it's not possible anymore to use a dataset for the available values nor for the default values of any parameter, even if the dataset itself is unrelated to the parameter in question.

Adey answered 12/12, 2012 at 8:49 Comment(1)
+1 for responding to an old question... thanks. I still lean towards the answer by @Paranoia because my issues were solved by deleting references to the report everywhere possible, then uploading again. However, I looked up your answer just now and I had no idea about any of that stuff when I was working with SSRS. I think your answer would have solved a lot of other issues I was having at the time when I wrote this question if I had only known.Dorrisdorry
D
1

I made a new report and copied the code over to the new report and saved it. It works perfectly now in that new report... I deleted the old one and renamed the new one, deployed to server and it everything is good. I wish I would have thought of this a lot sooner. SSRS is so funny, I don't even know what was actually causing the problem now, though...

any ideas on that?

(I had restarted SSRS a few times, restarted my computer a few times, deleted the .data files, deleted the copy off the server even though this was happening on my computer just to be safe... during all of this, btw)

Dorrisdorry answered 10/3, 2011 at 19:20 Comment(1)
JonH actually kind of had the answer to this but he put his suggestion as a comment, not as an actual answer.... When SSRS has problems like this it drives me crazy because there isn't actually anything wrong that is visible; the actual software is having issues.Dorrisdorry
G
1

I had the same issue as several others have indicated, where I had a parameter depending on another parameter that was listed after it.

However, just to be a little more clear for anyone else reading: If you are using Visual Studio 2019 like I am, then the cryptic "list" that everyone keeps referring to is the Parameters list that is found in the Report Data pane. You can access this pane in Visual Studio by going to View > Report Data at the top of Visual Studio.

enter image description here

For me, though, there were no up or down arrows. I had to literally open up the report's XML code (by clicking F7 or right-clicking the report file and selecting "View Code") and cut and paste the depended-upon parameter to the top of the Parameters section in the XML.

Guarantor answered 16/4, 2021 at 21:0 Comment(0)
L
0

I experienced similar problems with SSRS. The code was correct, the SQL parameters correct but the report was throwing parameter errors. I was using a Shared Dataset. I copied the same SQL to an Embedded Data Set and the report worked perfectly. So, I agree that the SSRS software has bugs that cause strange behavior.

Lashundalasker answered 26/12, 2013 at 19:11 Comment(0)
E
0

I also had this issue, following the all the answers above deinetely helped.

The tricky one with mine is that the dataset was an SSAS dataset therefore it was hidden. I had to search the code for the parameter to see where it was used and thats where I found it.

To view hidden datasets right click the Datasets folder in the Report Data tab and tick the 'Show Hidden Datasets' box.

Expanse answered 4/3, 2016 at 0:17 Comment(0)
Q
0

Happened to me too

There was one Parameters depending on another one

But the order of the depending one was on top

Used the arrows to move the calculated parameter to the end of all parameters.

Quixotic answered 12/6, 2018 at 0:36 Comment(0)
P
0

For me, I had to open rdl file and add my new parameter to the order/position(xml nodes) I want.

Puddling answered 15/1, 2019 at 15:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.