Solved

Reporting Services: How to know if the report is empty

Posted on 2008-10-20
12
689 Views
Last Modified: 2013-12-17
I am working on a web application which shows reports builts from Reporting Services. To show the report on the page I use a Report Viewer. I would like to know if there is a way to check whether the report has data before showing up the report.
0
Comment
Question by:karakav
  • 6
  • 6
12 Comments
 
LVL 12

Expert Comment

by:jgv
ID: 22760651
There's no method you can use through SSRS to check for this condition. You would have to independently run the same query that the report uses to see if there are any records. If you are asking because you want to show an appropriate message to the user in this situation there is a property for this. If you are using a List or Table object, look for the "NoRows" property. You can fill in a message that you want displayed on the report when no data is returned (ie: "No data was found matching your input")
0
 
LVL 4

Author Comment

by:karakav
ID: 22766260
What do you mean by "Using a List or Table"? Because me I directly show the report in a Report Viewer control.
0
 
LVL 12

Expert Comment

by:jgv
ID: 22766465
To set the NoRows property you have to edit the report in the report designer. This property should be available on the main object used to show the data (a Table, List, Matrix, etc). Did you build the report yourself or is this a report someone else built?
0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
LVL 4

Author Comment

by:karakav
ID: 22766663
I did it myself. The problem is that I don't manage to format that message so that I resemble the messages shown in the application.
0
 
LVL 12

Expert Comment

by:jgv
ID: 22767499
I'm not really sure what you mean by that last comment. Does the NoRows message shown in the report have to match something that is shown in your application (ie: the message can change each time the report is run?)

If you want to be able to set the NoRows message from your application you could create a "dummy" parameter that is set to Hidden and allows blank values. Pass a message into this parameter that will be shown if there is no data. The expression for the NoRows property would be something like this:
=Parameters!MessageToShowIfNoData.Value
0
 
LVL 4

Author Comment

by:karakav
ID: 22768378
My concern about the format is: For instance in the whole application, if a gridview doesn't contains data, I show a label with no data message. That label has same format: read font with special character. My problem is that inside the report designer, I can only define the no data message, but I can't define how that message will look like.
0
 
LVL 12

Accepted Solution

by:
jgv earned 500 total points
ID: 22768707
Ok. Assuming that you are using a table, try this instead.

Add a Table Header and merge the cells
Enter a "no rows" message and format it the way you want.
Select the row and enter this in the Hidden property (replace the field name and dataset name)
=IIF(Count(Fields!AFieldInYourDataset.Value,"YourDataSetName")=0,False,True)
0
 
LVL 4

Author Comment

by:karakav
ID: 22768983
And what do I do mi mu current table header?
0
 
LVL 12

Expert Comment

by:jgv
ID: 22769057
You can have more than 1 table header. Right click the table header row and select "Insert Row Above"
0
 
LVL 4

Author Comment

by:karakav
ID: 22769216
Yeah, I saw. The problem is that my columns are dynamic and I don't in advance which columns will be displayed.
0
 
LVL 12

Expert Comment

by:jgv
ID: 22769477
Your choices are pretty limited. You could place another table on the report just above your existing table. Only include the table header row with the message but set the Hidden property on the table itself.
0
 
LVL 4

Author Closing Comment

by:karakav
ID: 31507911
OK. I will try it. Thanks very much for you help. It was very much appreciated.
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello, In my precious Article  (http://www.experts-exchange.com/Database/Reporting/A_15280-Create-Project-in-Microstrategy-Part-I.html)we saw the Configuration part for Microstrategy which included Metadata Creation and DataSource Preparation as …
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

825 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question