[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 5024
  • Last Modified:

Crystal Decisions: Determine Record Count of Data Set used by report at runtime

I am running a report using .Net/C#/Crystal Decisions.  The report is loaded, assigned parameters, and either printed or exported entirely in code.  I need to find a way to check the Record Count of the Data Set returned by the view at runtime to determine whether or not to skip printing/exporting of the report.  I am using ReportDocument to handle the execution of this report.  I have looked as deep into ReportDefinition and other parameters as I can find documentation for.

Does anyone know how to access this number at runtime?  If not, do you have any ideas for other methods of determining if the report will be blank?  I've considered opening the DataDefinition and extracting the selection criteria used by the report but this will be very heavy on execution as it will require 2 large hits to the database should data exist.  I've also looked at taking this first initial query and passing it back to the report as the dataset if data exists, but this doesn't sound like it will run well for me.

Thoughts?  Ideas?

This is my first question posted at EE so I'm giving all my intial 125 points for the answer.  Please be kind with your responses.  I hope to be able to pay more after I earn some more points in the future.
0
Sevnn
Asked:
Sevnn
  • 2
  • 2
  • 2
  • +1
1 Solution
 
mlmccCommented:
Check the report options to see if there is an option to not print if no records.

mlmcc
0
 
ebolekCommented:
well dataset idea will work. That is one solution. I have never tries to get in the recordset of the reportdocument and i am positive that you cant. If you want to do that you should use push method (dataset) not pull method. There is nothing in the engine object model that is refering to as recordcount. However there is recordcount property of the crystal reports. And you should be able to access that. But maybe not in the version of .net bundled one. They have limited accessing the objects for .net and want you to buy the enterprise version :(

Regards
Emre
0
 
SevnnAuthor Commented:
mlmcc, I've seen this option but I am typically using ExportToStream, rarely if ever Printing.  I have to support both but the export side is used much more heavily.

ebolek, can you suggest any examples of push methods?  I've seen a few but they are usually pretty hacky.  I need to make sure it will work regardless of selection criteria and I will be running many different reports.  It will be a tremendous amount of work for me if I have to re-write any of the reports to get them to work with push instead of pull.  Is there another version of CR that supports a recordcount parameter?

Thanks guys, but I'm hoping there is a better solution.
0
Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

 
EwaldLCommented:
I have been unable to find a way to obtain the record count directly from a report within .net.

Not sure if this  would help you, but this article shows how you can obtain the number of pages from a report. So if you could design your reports in a way that each report without data will have 1 page only, and where each report with 1 record or more will automatically go over 2 pages then you would have a solution where you can stick to your current connectiviy model.
http://support.businessobjects.com/library/kbase/articles/c2013559.asp
0
 
ebolekCommented:
I dont know any version that supports the record count
Datasets are as you said not easy to implement but it gives you great flexibilit yon the recordset because you get the recordset programatically. These are the steps required to implement a dataset in areprot

1. Create a stored procedure, viewe etc to get the data from db
2. Create a dataset with the sp you just created
3. Write an app, to fill the dataset. Now the dataset has the necessary data filled
4. Create your report with the dataset as its source
5. Set the report source runtime witht he filled dataset.
6. Show the report

There is a dataset example in business objecs. Read this
http://support.businessobjects.com/communityCS/TechnicalPapers/rtm_reportingoffadonetdatasets.pdf.asp

Hopefully it helps
Regards
Emre
0
 
EwaldLCommented:
You coudl use the craxdrt to obtain the recordcount, but I would not recommend this for a web application (it's not scalable) and I would not like to use it in .NET either (not meant to be used this way, you would not  use the .net assemblies)

but anyway, this code would get the value. it has to be executed though once the report has been fully formatted
MsgBox  crReport.PrintingStatus.NumberOfRecordSelected
0
 
SevnnAuthor Commented:
I was hoping for a solution that did not require pushing a dataset into the report object.  I am looking into the Enterprise versions of CR.  If they do not support it or of they are out of my $ range I will be attempting the push method (but only as a last resourt).

Thanks everyone for your input.
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 2
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now