cancel
Showing results for 
Search instead for 
Did you mean: 

Crystal Reports for VS2010 version not selecting records correctly

Former Member
0 Kudos

On a clean machine, I installed VS2010 and the CR v13.0.5 for integration with VS2010.  After doing a little work to fix the application references to the appropriate CR DLLs, the app compiles and runs without issue.  However, the CR viewer object is not selecting data correctly when the binding happens.  It appears as if at least the date range selection is not happening.  There are internal formulas doing specific work on specific columns of the records, so if the entire filter is malfunctioning, the formulas are masking it off.

The report results are presented having selected a larger date range of information than requested.  When I press the Refresh button on the report viewer, and accept the exact same paramters as previously provided, the report then selects the correct data and presents as it should have the first time around.

My app is using WinForms and primarily embedded CR objects.  There is a mechanism to handle manually specified RPT fils for ad hoc reports. The problem happens regardles if I use the embedded report object, or an RPT passed in.

About the app:

I have a dedicated class library that contains all the objects needed to execute the report requests:

1)  an inherited System.Windows.Forms.Form object

2)  the form contains a CrystalDecisions.Windows.Forms.CrystalReportViewer object

3)  all the crystal report definitions that become the embedded objects at compile time

4)  each customizable query (dates, date ranges, support table selections, or multi-selects) handled programatically when a report is requested

The Form_Load and CrystalReportViewer_ReportRefresh events drive the binding process, each calling the same BindReport().  This method differentiates if the binding is to be accomplished using an embedded report object, or if an ad hoc RPT document was provided.  For the latter, the report document is simply assigned to the CrystalReportViewer.ReportSource.  The former has a few more steps involved, but not complicated overall.

The binding process for the embedded reports first creates an instance of the report object cast to a ReportClass object, applies and validates the LogOnInfo for each table, and (if existing) each subreport table, and executes the programatically provided queries to be performed.  The queries are programatically associated to Parameters defined within the report.  The query results are saved to the designated report Parameter using one of the ReportClass.SetParameterValue() overloaded methods.

The last step is to simply assign the ReportClass object to the CrystalReportViewer.ReportSource.

This is where the problem is exibited. the report view sussessfully presents the report after what seems to be a full table scan on the source (as if there was no record selection filter).  Refreshing the report presents repeats the bind process and the report results are correct..

In the debugger, I am able to verify a RecordSelectionFormula exists and I am setting the Parameters appropriately as those values are displayed in the report header.  There is just nor real way to tell what is (or not) being used at query time, as that is all executed by Crystal when the binding/assignment to the ReportSource is completed. 

Interestingly though, in the CR designer, the select expert shows the expected record select formula, but the Show SQL Query... option does not include the date filter.  This seems relevant, but I must admit I have not previously noticed this either way.

I first encounter this using CR v13.0.4.  I uninstalled and upgraded to v13.0.5 (to no avail) after coming across SAPs KBA 1811876.

The development environment is Windows 7 Enterprise SP1 64-bit (fully patched with security and critical updates), VS2010, SqlServer 2005 (9.00.5069) on Windows 2003 server.  Also tried using a Windows 7 Enterprise SP1 (32-bit) machine.  No difference.

I am attaching a code snip from my project that shows the binding process that occurs.

Thanks in advance for any help/guidance on this.

Tom Stratford

City of Henderson, NV

Dept. of Utility Services - SCADA

View Entire Topic
former_member183750
Active Contributor
0 Kudos

Hello Tom

Your query was posted in an incorrect SCN Space. I moved it here, which is the correct place for it.

My 1st step to troubleshooting the issue would be a new one line app:

CrystalReportsViewer1.ReportSource = <path to the report>

If the report does not have saved data, it will prompt for a db logon. Please enter that in the logon dialog and see what the report looks like in this test app.

- Ludek

Follow us on Twitter

Got Enhancement ideas? Try the SAP Idea Place

Share Your Knowledge in SCN Topic Spaces