SSRS report not displaying data

假装没事ソ 提交于 2020-06-09 12:03:09

问题


I have just created an SQL Server 2005 SSRS report and the data is not being displayed in the Preview pane.

The dataset is correctly populated from a stored procedure against a String parameter. I can execute it in the Data pane. When running the report in the Preview pane the correct number of rows are displayed but the contents of the cells do not contain any data

Missing Data

The source dataset is based on a Stored Procedure with a passed in String parameter in SQL Server 2005 that return the contents of a temp table. The dataset then maps the fields to locals. I can execute this correctly in teh Data view.

Stored Procedure

ALTER PROCEDURE spWebReportStage25BuildReview
    @BuildNumber as nvarchar(50)

Temp table schema

CREATE TABLE #tmpModelZones
(
    BuildID bigint NOT NULL,
    BuildNo nvarchar(50) NOT NULL,
    ModelID int NOT NULL,
    ModelName nvarchar(50) NOT NULL,
    ZoneID int NOT NULL,
    ZoneName nvarchar(50) NOT NULL,
    SortOrder int NOT NULL,
    Created bit DEFAULT 0 NOT NULL,
    Closed bit DEFAULT 0 NOT NULL,
    PRIMARY KEY (BuildID, ZoneID)
)

SSRS Dataset

enter image description here

SSRS Dataset mapping

enter image description here

SSRS Dataset Parameter enter image description here

Executing Dataset with parameter

enter image description here

There are no additional grouping, filters or aggregation on the displayed table. It is simply a flat table


回答1:


When using temporary tables, SSRS fails to get the metadata. So there are basically 2 ways of letting SSRS know the column names:

  1. Add SET FMTONLY ON. This will retrieve the metadata but it won't display the data.

  2. Go to the DATA tab and click on the Generic query designer and click refresh fields. This will prompt a dialogue box for specifying the parameter value. When we run the query in query designer SSRS gets the schema and the data from the stored procedure. Now the data will be available in preview pane.




回答2:


Never seen this before. However, SSRS can be a bit "off" at times, so here's a list of things to try. I'm afraid most of these are of the type "Have you tried turning it off and on again?".

  • Delete the .data files associated with the report.
  • Duplicate/back-up the report, and try to add the dataset in a fresh, basic tablix to see if that does show data.
  • Check the hidden property. Don't forget that (for some stupid reason) it's not (like in any other sane product) a Visible Y/N field, but a Hidden Y/N field.
  • Double check font color and size, etc.
  • Run the report on your reportserver (as opposed to the preview) to check if that does work.
  • Use some temporary text boxes to show the actual values of your parameters, to check if they are exactly the same as when you test-run the data set.
  • Check the code-behind (xml in the rdl) for unexpected filters, hidden property, expressions, etc. in the tablix. Even if you can't quite "read" the RDL, with syntax highlighting you should be able to skim it and extract a lot of info on this.
  • Check the ExecutionLog2 and other logging stuff to see how many rows are being returned in report runs.

In addition, it would help if you update/edit your question with some more info:

  • What kind of groupings does the tablix have?
  • What are the filters on the tablix, row groups, and column groups?
  • What is the general structure of the dataset, and it's results?
  • How are the parameters structured and used?



回答3:


I also had a similar issue. In my case, it even occurred without any parameters or anything, just the most simple report you can imagine. It included a table with a single field, no filters were used. I did manage to view some data, but only those lines were shown which did not fit into the cell and thus forced the row height to increase.

My fix for this issue: changing the font or the font size from the standard (size 10, Segoe UI). Then, all data was showing. Changing this back to Segoe UI made the data disappear once again.




回答4:


I had the same problem. Here is what I found. Here is my code:

    DECLARE @tblPigProblems TABLE (
    Id          INT IDENTITY, 
    PPId            INT, 
    GaugeColor      VARCHAR(25), 
    FullStartTime       VARCHAR(25), 
    PigSystem         VARCHAR(25)
    )

    IF (1 = 0)
    BEGIN
        SELECT * FROM @tblPigProblems
    END

    ...

    SELECT '@tblPigProblems'    [PigProblems],  
    @p_vchLine      [Line],         
    GaugeColor      [Product],
    FullStartTime       [Start Time],
    PigSystem       [Pig System]
FROM @tblPigProblems

What I did was to use the initial "SELECT * FROM @tblPigProblems" to ensure that if any error messages were specified in the code before the final select statement returning the dataset, that SSRS was able to determine the fields from the stored procedure. Then, when the results were determined, I assigned an alias to the fields. The problem was that the aliases for the fields did not match the declared field names (ie: the declared field "GaugeColor" did not match the alias "[Product]" I supplied in the select to create the result set. The way that I realized this is that when I refreshed the fields in the Data section of the SSRS report, then displayed the dataset fields, it listed the field names from the table declaration (ie: "GaugeColor"). When I executed the stored procedure within the dataset (clicked on the !), the result set listed in SSRS showed the field aliases (ie: "Product"). Since these didn't match, nothing was displayed in the textbox I had assigned the field to (ie: "=Fields!ColorGauge.Value"). SSRS did not pick up this discrepancy and allowed the report to be created, but no values to be displayed. The fix was simple, replace:

    IF (1 = 0)
    BEGIN
        SELECT * FROM @tblPigProblems
    END

with:

    IF (1 = 0)
    BEGIN
        SELECT '@tblPigProblems'    [PigProblems],  
        @p_vchLine      [Line],         
        GaugeColor      [Product],
        FullStartTime   [Start Time],
        PigSystem       [Pig System]
    FROM @tblPigProblems
    END

Dan




回答5:


I had a case where a working report stopped displaying data. I added another table with no formatting, linked to same dataset - verified that the query no longer returned data when passed parameters by SSRS. After investigating, I noticed that my test parameter for a "anchor date" value was formatted as YYYY-MM-DD, and in my updated query, I was making assumptions about the order of the characters in the date parameter (to truncate to YYYY-MM for one join).

I suspected that SSRS may be passing the date in a different format (MM/DD/YY being my current cultural setting for date defaults). So running with that hunch, I changed my SQL logic to work with any date format passed. - e.g. left(convert(date, @anchorDate, 20), 7)

This fixed my problem - the format assumptions that I had tested with (hard coded values to test the query while developing) were bad assumptions. SSRS can pass data in local formats as well - so be sure to watch out for this kind of assumption.



来源:https://stackoverflow.com/questions/11359194/ssrs-report-not-displaying-data

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!