Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2004-11-01
8
Medium Priority
?
5,022 Views
Last Modified: 2008-01-09
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
Comment
Question by:Sevnn
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +1
8 Comments
 
LVL 101

Expert Comment

by:mlmcc
ID: 12467771
Check the report options to see if there is an option to not print if no records.

mlmcc
0
 
LVL 10

Expert Comment

by:ebolek
ID: 12468058
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
 
LVL 1

Author Comment

by:Sevnn
ID: 12468110
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
Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

 
LVL 13

Expert Comment

by:EwaldL
ID: 12512770
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
 
LVL 10

Accepted Solution

by:
ebolek earned 375 total points
ID: 12525761
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
 
LVL 13

Expert Comment

by:EwaldL
ID: 12527400
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
 
LVL 1

Author Comment

by:Sevnn
ID: 12729204
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question