Quantcast
Channel: SQL Server Reporting Services, Power View forum
Viewing all articles
Browse latest Browse all 10045

SSRS Report Builder - Must Declare the scalar variable

$
0
0

Hi,

I've recently moved a LOB application from on-premise to the cloud. I want to continue to use the SSRS services on my SQL 2008 server but with the database now in the cloud. I have been given the login credentials to allow me to connect via OLEDB. I can build a SSRS report using Report Builder 3.0, create the OLEDB data source, add a dataset e.g. SELECT company_recid FROM v_Company and bind to a report table not a problem. When I preview the report using my browser all is working fine.

My problem comes with using parameters. 

I have created a parameter in the report called @param1 (int). When I modify the dataset with the command text of "SELECT company_recid FROM v_Company WHERE company_recid = @param1, I get an error saying "Must Declare the scalar variable @param1.

It's as though the dataset is not inheriting the report parameter but instead is looking at the parameter in isolation. I have modified the dataset parameters collection to bind the report parameter to a parameter of the same name in the dataset and this still gives an error.

If in the dataset command text, I add "DECLARE @param1 int;" at the top then the error disappears but I'm left with an empty dataset and no fields because the value of @param1 is NULL. If I add "DECLARE @param1 int=123;" then this works fine, I get my field list and the record with company_recid of 123. This however is not what I want - I'm effectively embedding a static variable in my report. 

If I create my dataset command text as an expression and issue the following:-

"SELECT company_recid FROM v_Company WHERE company_recid = " & =Parameters!param1.Value

then this works but it can't resolve the fields list so I can't bind these to the report?

Anyone got any ideas?



Viewing all articles
Browse latest Browse all 10045

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>