Solved

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

Posted on 2004-11-01
5,015 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
Question by:Sevnn
    7 Comments
     
    LVL 100

    Expert Comment

    by:mlmcc
    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
    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
    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
     
    LVL 13

    Expert Comment

    by:EwaldL
    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:
    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
    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
    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

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Suggested Solutions

    There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
    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 Experts Exchange video Micro Tutorial, I'm going to show how small business owners who use Google Apps can save money by setting up what is called a catch-all email address in their Gmail accounts. By using the catch-all feature, small busin…
    how to add IIS SMTP to handle application/Scanner relays into office 365.

    845 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

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now