Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 donot dispay report if all datasets are empty

Author  Topic 

nitsmooth
Yak Posting Veteran

68 Posts

Posted - 2009-12-10 : 04:29:59
Hi, actually i have made the visibility expression for a dataset as "=IIf(CountRows()=0,true,false)".
So if there are no records for the dataset, the dataset is not visible at all.
But nw what i want is that if all the datasets in my report are empty(i have 6 dataset tables in single report) and hence not visible then the report should not be generated at all.
Actually i have scheduled the reports to run every hr thru subscriptions.

cant we write something in the reportproperties->code, that will check if all datasets are empty and generate an error (). If its so cud u plz provide me with a expression for it.

gangadhara.ms
Aged Yak Warrior

549 Posts

Posted - 2009-12-10 : 04:57:57
Hi,
you can write an expression relating to each dataset explicitly for example
=IIf(CountRows()=0,true,false,"Dataset1",CountRows()=0,true,false,"Dataset2",)" something similar to like this try you can write the expression.Check for syntaxes.

Thanks,
Gangadhar
Go to Top of Page

nitsmooth
Yak Posting Veteran

68 Posts

Posted - 2009-12-10 : 05:21:18
If you are asking me to try this in ReportProperties->custom code then i already did. It is giving syntax error.



Go to Top of Page

nitsmooth
Yak Posting Veteran

68 Posts

Posted - 2009-12-10 : 09:00:44
i tried this in reportproperties->code:

Function Dataset()
if(CountRows("DataSet1")=0) then
RAISERROR('no records found',16,1)
End If
End Function

but it gives error says : CountRows is not declared
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-12-10 : 13:48:25
you've no rows property for containers like tables in report where you will give a message to display when it doesnt have any data to display
Go to Top of Page

nitsmooth
Yak Posting Veteran

68 Posts

Posted - 2009-12-11 : 00:08:52
actually i dont want no msg to be displayed ... all i want is to generate some error in the report when there are no rows for the dataset so that the report is not sent to the recepient thru subscription ...when the datasets are empty
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-12-11 : 12:00:55
then is nt it better to call the reporting services report from web application based on if data is present or show error and send email from app based on the status?
Go to Top of Page
   

- Advertisement -