Skip to Content

.NET for Visual studio 2015 not refreshing data or filtering data as per parameters

Feb 07, 2017 at 02:01 PM


avatar image


I have conducted a reasonable amount of searching relating to this problem but no solution has been found yet.

Basically, I have a Crystal report viewer in a C# Windows forms application which allows the user to browse to a .rpt and open it. All report files already have the datasource embedded.

Reports opens fine but ignores the parameters chosen and show all the data regardless of the parameters and does not work even after using the viewers refresh button.

I have confirmed that the reports(I have tried multiple reports from multiple difference data sources) have the option "Discard saved data" selected and the Save data with report option un-ticked.

Also please note the commented refresh method calls for both the report document and the viewer but neither of them worked.

Please note that I'm new to .NET development and might be missing something or going about it the wrong way.

Extra information that might be useful:

SAP Crystal report runtime engine:

SAP Crystal reports, version for VS



public void Crviewer(string file)
            CrystalReportViewer tempViewer = new CrystalReportViewer();
            ReportDocument tempCover = new ReportDocument();
           // tempCover.Refresh();
            ActiveForm.Size = new Size(1325, 658);
            tempViewer.ActiveViewIndex = -1;
            tempViewer.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
            tempViewer.Dock = DockStyle.Fill;//| System.Windows.Forms.DockStyle.Right;
            tempViewer.Padding = new Padding(-1, 23, 0, 2);
            tempViewer.Name = "tempViewer";
            tempViewer.SelectionFormula = "";
            tempViewer.TabIndex = 0;
            tempViewer.ViewTimeSelectionFormula = "";
            tempViewer.ReportSource = tempCover;
            tempViewer.Location = new Point(1325, 27);
            tempViewer.AutoSize = true;
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Best Answer
Neel Patel Feb 08, 2017 at 04:27 PM

Hi Don,

So I found the problem and looks like I messed up in the code. All our record selection is done using Selection formulas and because of the line:

tempViewer.ViewTimeSelectionFormula = "";

It was overwriting the selection formulas. Removing this line resolved the problem.



10 |10000 characters needed characters left characters exceeded
Don Williams
Feb 07, 2017 at 02:09 PM

Hi Neel,

First, your runtime and VS installs need to be the same version. Uninstall CR for VS from your DEV PC and runtime if you installed both.

SP 19 is out now also so update your DEV PC with the first link to integrate into VS. DO NOT install the runtime on your DEV PC.

You are not setting DB log on at all so that needs to be done as well.

In the properties of the viewer set ReuseParameterValuesonRefresh to false.

Comment out the Line to Refresh().

See KBA 2163438 for simple viewing and printing reports with saved data and KBA 2281780 for using log on API's and Parameter API's.


Show 1 Share
10 |10000 characters needed characters left characters exceeded

Hi Don,

Thank you for your reply and the KBA's, I will read them over.

However, my understanding is that since I'm using a DSN file for all the reports which contains the DB logon and all the reports have this DSN file referenced. Do I still need to set the DB logon?

I ask this because when I use VS to open a Crystal report and preview, it uses the DSN file to grab the data.

I'm trying to achieve similar sort of functionality, this application will basically allow the user to open any report and enter the parameters(stored within the report itself) and view the report, is that not possible?