cancel
Showing results for 
Search instead for 
Did you mean: 

Refresh() not working in the CCrystalReportViewer11.

Former Member
0 Kudos

Dear All,

I am using CR X1 RDC report viewer. When I click on the Refresh button in the report viewer, the crystal report getting updated with the latest data base values. I have tried to refresh the crystal report through code by using the Refresh() function in the m_Viewer. But it is not working. The code snippet i have given below for your reference.

CCrystalReportViewer11 m_Viewer;

IApplicationPtr m_Application;

IReportPtr m_ReportType;

m_ReportType = m_Application->OpenReport(FilePath);

GroupName = (_bstr_t)csGroupName;

m_ReportType->FormulaFields->GetItemByName("GroupName")->Text = GroupName;

/* To hide the Preview section */

m_Viewer.SetEnableGroupTree(0);

/* To hide the Border */

m_Viewer.SetDisplayBorder(0);

/* To hide the Preview Tab*/

m_Viewer.SetDisplayTabs(0);

m_Viewer.SetReportSource(m_ReportType);

m_Viewer.Refresh();

m_Viewer.ViewReport();

m_Viewer.Refresh();

Please suggest me to make it work.

Regards,

Rahaneef T

Accepted Solutions (1)

Accepted Solutions (1)

former_member183750
Active Contributor
0 Kudos

Try discardSavedData(?). Or, doing the same thing in the CR designer; go to the File menu and ensure there is no checkmark next to Save data with report.

Now, not having a db logon, depending on the database, you may get a db logon error as the code is now...

Ludek

Answers (1)

Answers (1)

0 Kudos

Hi Rahaneef,

Once the object and data is in memory refresh will use that info each time. It's basically a report with saved data so to refresh the data you need to use m_ReportType.DiscardSavedData in your loop before the refresh called the second time. This also re-runs the report.

Thank you

Don

Former Member
0 Kudos

Dear All,

I have tried as you told. It is working fine.

Thank you for your kind support.

Regards,

Rahaneef