简体   繁体   English

SSRS 在报告中不显示任何记录,但查询返回结果

[英]SSRS shows no records in report but query returns results

I have a question according to SSRS.根据 SSRS,我有一个问题。 I am working with MSSQL Server management studio 2012 and BIDS Visual studio 2008 for the report design.我正在使用 MSSQL Server management studio 2012 和 BIDS Visual Studio 2008 进行报表设计。

I have a report with some multivalue parameters and a stored procedure in behind which returns the records.我有一个带有一些多值参数的报告和一个返回记录的存储过程。

Now I've tried to find the problem on the parameter values passed to the stored procedure and a string split function.现在我试图找到传递给存储过程和字符串拆分函数的参数值的问题。 I looked in the SQL server profiler if the strings get passed in an unexpected form but thats not the case.如果字符串以意外的形式传递,我查看了 SQL 服务器分析器,但事实并非如此。 I ran the exact execution code in the server as a query and got results back.我在服务器中运行了确切的执行代码作为查询并得到了结果。 but if i run the report in the preview pane of the report designer i get no results back.但是如果我在报表设计器的预览窗格中运行报表,我将不会得到任何结果。

If you need any additional infos, just let me know.如果您需要任何其他信息,请告诉我。 I just thought there may be someone who faced the same issue and knows the response.我只是认为可能有人面临同样的问题并且知道回应。

"

I will take a guess and say it is 'how' you are passing the multi value parameter. 我会猜测并说你是如何传递多值参数的。 Personally when dealing with SSRS I use views, table functions, or just selects as SSRS can understand natively that this: 在处理SSRS时,我个人使用视图,表函数或只是选择,因为SSRS可以原生地理解这个:

Where thing in (@Thing)

Actually means this in SSMS: 实际上在SSMS中意味着这一点:

Where thing in (@Thing.Value1, @Thing.Value2, @Thing.Value3, etc...)

I am guessing your proc is taking a string that is actually a comma seperated array. 我猜你的proc是一个字符串实际上是一个逗号分隔数组。 When you do a parameter that takes a string array like '1,2,3,4' and you are addressing the procedure with something like a 'Text' parameter accepting multiple values you either specify or get from a query you essentially need to 'Join' the parameters if your procedure takes a value of a string that contains the array. 当您执行一个带有像'1,2,3,4'这样的字符串数组的参数时,您正在使用类似'Text'参数接受多个值的过程来处理该过程,您可以指定或从查询中获取您基本上需要'如果您的过程采用包含该数组的字符串值,请加入'参数。 EG: Proc called dbo.test executes to return rows for values 1,2,4 for a parameter ids are shown like: EG:Proc为dbo.test执行以返回值为1,2,4的行,参数ID如下所示:

exec dbo.test @ids = '1,2,4'

If I wanted to run the proc in SSRS with this value and I had a multi value parameter called 'IDS' I would have to assemble the array manually in a function in SSRS like: 如果我想用SSRS在SSRS中运行proc并且我有一个名为'IDS'的多值参数,我将不得不在SSRS中的函数中手动组装数组,如:

=JOIN(Parameters!IDS.Value, ",")

Essentially telling the proc run a parameter 'IDS' by joining together the multiple values in a chain of comma seperated values. 基本上告诉proc通过将逗号分隔值链中的多个值连接在一起来运行参数'IDS'。 You do this in the dataset on the left pane where it lists 'Parameters' instead of specify the Parameter as it is like [@IDS] you click the 'Fx' instead and put in the function above. 您可以在左侧窗格中的数据集中执行此操作,其中列出了“参数”,而不是指定参数,因为它类似于[@IDS]您单击“Fx”而是放入上面的函数。

For this reason I am a big proponent of views, selects, and table functions as you can use the predicate logic to take care of this. 出于这个原因,我是视图,选择和表函数的主要支持者,因为您可以使用谓词逻辑来处理这个问题。

This answer might look outdated but in case someone needs it I will just reproduce my experience since I had the same problem just yesterday and I the solution from a webpage. 这个答案可能看起来过时但如果有人需要它,我将重现我的经验,因为我昨天遇到了同样的问题,我从网页上解决了这个问题。

The problem: My report has 2 date parameters so to get data between that range, but i first noticed it did not work for 1 day, then I noticed that using a range did not bring the data in the last day 问题:我的报告有2个日期参数,所以要获取该范围之间的数据,但我首先注意到它没有工作1天,然后我注意到使用范围没有带来最后一天的数据

Workaround: I worked with the query, making some arrangement but when i made the query to return a whole month and nothing happened in the report i knew all the problem was in SSRS, of course I checked the parameters I was sending to the report. 解决方法:我使用了查询,进行了一些安排但是当我查询返回整整一个月并且报告中没有发生任何问题我知道所有问题都在SSRS中,当然我检查了我发送到报告的参数。

Solution: My date parameters were OK (no problem with the time part) and I read somewhere to check for the filters in the "Data" Panel, that is the other tab besides the parameters. 解决方案:我的日期参数没问题(时间部分没有问题),我在某处查看了“数据”面板中的过滤器,这是参数之外的另一个选项卡。 I had put those filters and totally forgot about then. 我放了那些过滤器,完全忘记了。

You haven't provided a repro or any details, so it's really a guessing game for us. 你没有提供repro或任何细节,所以这对我们来说真的是一个猜谜游戏。 Answering the question "What can I do to debug unexpected (no) data being rendered in preview?" 回答“我该怎么做才能调试预览中呈现的意外(否)数据?” can be done with at least: 可以至少完成:

  • Delete the .data files (Visual Studio heavily caches data) 删除.data文件(Visual Studio大量缓存数据)
  • Reboot Visual Studio (yes, unsatisfactory, but with SSRS it's helped my out on occasions) 重新启动Visual Studio(是的,不满意,但是使用SSRS它有时帮助了我)
  • Check the ExecutionLog2 table in the ReportServer database to debug (RowsAffected and such) 检查ReportServer数据库中的ExecutionLog2表以进行调试(RowsAffected等)
  • Run SQL profiler to check the query and results being returned 运行SQL事件探查器以检查查询和返回的结果

My problem was that I did not add the parameter for the report to the dataset. 我的问题是我没有将报告的参数添加到数据集。 You have to right click on the dataset in the Report Data tab, and refresh the fields of the stored procedure. 您必须右键单击“报表数据”选项卡中的数据集,然后刷新存储过程的字段。 You can also add a parameter manually in the Fields menu item in the dataset properties window. 您还可以在“数据集属性”窗口的“字段”菜单项中手动添加参数。

I ran into this and when I added the parameter value to the report, it automatically put in =Parameters!parametername(0) , which caused no records to be returned because parameter(0) correlated to a value that wasn't in the data. 我遇到了这个,当我将参数值添加到报表时,它会自动输入=Parameters!parametername(0) ,这导致没有返回任何记录,因为parameter(0)与数据中没有的值相关。

If you see an <exp> in the Value field, change it to the [@parametername] (I ran into this using the filter property of the dataset.). 如果在“值”字段中看到<exp> ,请将其更改为[@parametername] (我使用数据集的filter属性进行了此操作)。 It allows you to create a semi-dynamic filter and I chose fieldname and then I chose IN as the comparative. 它允许您创建一个半动态过滤器,我选择了fieldname然后我选择IN作为比较。 Later I created an expression that got that messed up (0) value. 后来我创建了一个表达式,它得到了混乱的值(0)

Not sure if this is relavant but, my datasouce was using a MySql connection so while i could not get @parameterName to work, I replaced it with ?不确定这是否相关,但是我的数据源使用的是 MySql 连接,所以虽然我无法让@parameterName工作,但我将其替换为?
so instead of WHERE Customer.CustomerID = @CustID所以而不是WHERE Customer.CustomerID = @CustID
I used WHERE Customer.CustomerID = ?我用WHERE Customer.CustomerID = ?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM