How do I not print blank reports?

  • Hi,

     

    Currently I am programmatically printing SQL Server Reporting Services reports using a C# console application (most of the code I got from Bryan Keller’s weblog http://www.csharphelp.com/archives3/archive545.html).

     

    The problem I am having is that when a report is blank (i.e. its data sets don’t return any data) I don’t want it to be printed. If I don’t want a blank Access report to print I set the following event in VBA:

    Sub Report_NoData(Cancel As Integer)

                Cancel = True

    End Sub

     

    Then any code that tries to print this report will receive an error when it is blank. I can then capture the error and the report won’t print.

     

    I am wanting to do a similar thing when printing SQL Server reports. My ideas so far have been to:

    1)      Somehow programmatically execute the DataSets used by the SQL Report. So far I have not found anything within the ReportingService web service to do this.

    2)      Set an Expression on the NoRows property of the SQL Server report, that will compile, but when a report is Rendered that has no data, an exception will be thrown. This exception could then be caught and the report wouldn’t be printed. I haven’t been able to come up with a statement to achieve this either.

     

    Has anyone else had any luck with this sort of thing? Any help is appreciated.

     

    Thanks, Matt

  • Matt
    i had similar situation and what i did was i exported to XML and loaded into a dataset (dataset.loadxml) and that gave me ability to check record count.
     
    probably you can do something like that
  • Sounds like a good idea if I can work out how to export to XML programmatically. I will give it a go in the next few days and let you know.

    Matt

  • Matt
    you can look at samples provided by MS.
    there is already a solution which has code export a report to xml format.
     
    if you installed in default location then should find samples in following location
    C:\Program Files\Microsoft SQL Server\90\Samples\Reporting Services

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply