0

Can we add RAISE ERROR in the command text of the RDL file for an SSRS Report?

My report is creating a blank PDF file due to missing data in the DB. I want to check the data, and if no data is found I need to raise the error. Is that possible?

Or after render call, how can we check the content data for the file? Is there any way to do that?

We are using SSRS-2008-R2 version. and we are running thereports through a C#.net Application, so, i invoke the report through a Reporting Services's WebServices, and it return a byte array that represent the result of the reports, but the array byte always bring byte because, the reports has a header, hence occurs bytes.

i need to check the byte array to decide whether to generate the pdf or not.

How can i do that .?

Sahi
  • 1,454
  • 1
  • 13
  • 32

1 Answers1

0

There is a built-in function in SSRS that allows you to check if a DataSet has any rows.

=CountRows(“DataSet1”)

You can always check that and take appropriate action(s).

I like to use this in the Hidden property for a Tablix/Matrix, and hide it when the row count is 0.

=IIf(CountRows(“DataSet1”) = 0, True, False)

Also, I like to add a text box to the report that simply contains the words No data to report. Then I show that when the dataset is empty via it’s Hidden property.

=IIf(CountRows(“DataSet1”) <> 0, True, False)

No need to do a raise error, handle the problem with a little finesse. This works with all versions of SSRS.

EDIT:

Another way to do that is use a stored procedure for the dataset source. Handle all that logic there. Select the data into a temp/working table, check if the row count is 0, take whatever action you need to (send email, return data, or both).

Another way could be a data driven subscription; that is available if you are running SSRS enterprise edition. Then you could get a report that would alert you to any data anomalies you want to monitor for.

R. Richards
  • 24,603
  • 10
  • 64
  • 64
  • if the CountRows() return 0, then i need to get some messages. how can do that .? – Sahi Jan 11 '17 at 13:02
  • What do you mean by get some messages? – R. Richards Jan 11 '17 at 13:05
  • i am queuing the generate pdf request in msmq and reading the data from replication DB. by the time msmq start processing the request, replication is not happened. hence data set will be empty. if the dataset is empty, return some message or empty dataset from the ssrs RDL and enque the request in msmq again. – Sahi Jan 12 '17 at 06:45
  • And here I thought we were talking about a report, not a full blown application! You should think about asking that questions again, but with some appropriate tags, and the details that would allow someone to answer it. – R. Richards Jan 12 '17 at 12:44