SAP Knowledge Base Article - Public

1290058 - How to filter the data without hitting the database again, once the data is fetched from the database.


The Crystal report is supposed to bring in all the data from a table or tables, based on the report designed in Crystal Report designer, but only selected data is to be displayed by the ReportViewer control in a .NET application.

Reproducing the Issue

  • Crystal Reports XI Release 2.
  • Visual Studio 2003.


Using the ViewTimeSelectionFormula property of the CrystalReportViewer control, to filter data, just before displaying the selected data, in the report, not only reduce the number of hits to the database but also display the required data to the user. So the report brings all the data from the database and the Viewer control filters the data before displaying it on the report.

Code to use this property: 

// creating a report object (in VS-2003)
MyReport Report = new MyReport();

// Applying the filter for the data to be displayed. for eg. "DATE({Orders.OrderDate}) <= #8/1/1996#";
CrystalReportViewer.ViewTimeSelectionFormula = "DATE({Orders.OrderDate}) <= date_value";

// Displaying the report.
CrystalReportViewer.ReportSource = Report;


Using the Viewer Object Model and the ReportDocument Object Model interchangeably is not recommended.


.net, filter data before viewing, vs2003, vs, cr, crxi , KBA , BI-DEV-NET , BI Software Development Kits (SDKs) - .NET or Other , How To


SAP Crystal Reports XI R2