how do I force CrystalReportViewer to refresh its data?

  • Thread starter Thread starter Bob
  • Start date Start date
B

Bob

I'm asking here because I've posted this question in the crystal newsgroup,
waited two weeks, and got zero response. I would be very appreciative if
someone could shed some light on this problem for me.

I'm using the CrystalDecisions.Windows.Forms.CrystalReportViewer available
in CrystalDecisions.Windows.Forms.dll, version 9.2.3300.0.

Why does the crystal report viewer refuse to reload its data when the
RefreshReport method is called if the report parameters haven't changed? Can
I force it to always refresh or will I have to cobble together an ugly
workaround?

Bob
 
For future reference to others that may find my post, subclassing
ReportDocument and overriding the RefreshReport method is not a viable
option because CrystalReportViewer will not trigger a reload of data if it
sees that the parameters in its ReportDocument haven't changed. You have to
handle the ReportRefresh event (there is no override) in CrystalReportViewer
itself and in it 1. call the refresh method of the report document, 2.
update its parameters, then 3. set CrystalReportViewer's report source to
its report source (no change).

IMHO this is rather clunky, almost smells like a workaround to less than
well-thought-out design. But they refuse to call any behavior a "bug",
probably to keep the $200 I paid them to impart the knowledge I'm sharing
here.

I really dislike Crystal now. I may be stuck with it in my current
deployment but I'm going to looking for other DotNet reporting solutions
(purely DotNet, not this bastardized COM crap) when I have the opportunity.

Bob
 
Bob - thank you so much, it worked perfectly. In my case, the report took no parameters, so the code was simply:

CrystalReportSource1.ReportDocument.Refresh();
CrystalReportViewer1.ReportSource = CrystalReportSource1;

Thanks again - saved me a lot of work!
John

 
Back
Top