0
votes

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 .?

1

1 Answers

0
votes

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.