Skip to Content

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

Feb 07, 2017 at 09:32 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 data-source 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.

Here is the core method that creates the viewer and opens the reports:

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;

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



10 |10000 characters needed characters left characters exceeded

Hi Neel,

I don't see where your report is logging onto the database. It's interesting if you have unchecked Save Data but still getting data in the report. What is you datasource and how is the report connecting to it?

I've had databases where no password was required so no logon was needed. Most databases require some sort of logon. I'd bet if you tried the logon, you'll see the proper data come up on the report. Or an error at least.

Good luck,


* Please Login or Register to Answer, Follow or Comment.

4 Answers

Best Answer
Neel Patel Feb 08, 2017 at 07:55 PM

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.



10 |10000 characters needed characters left characters exceeded
Neel Patel Feb 08, 2017 at 02:14 PM


My datasource is a DSN file that contains the logon information and the DSN file is mapped within the reports themselves. So I don't see the need for setting the logon information.



10 |10000 characters needed characters left characters exceeded
Neel Patel Feb 08, 2017 at 07:56 PM

Hi Brian,

My datasource is a DSN file on the server and that file contains the credentials and server details. Interestingly when I open the Crystal reports through SAP Crystal report program or VS it opens fine and displays the correct data as per parameter selection. So it must indicate that I'm doing something wrong.



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

Hi Neel,

I did answer this but I don't see it.... Anyways, you should not mix runtime versions.

Go to this link and get SP 19:

First, uninstall CR for VS on your DEV PC, if you install the Runtime MSI uninstall that also. On your DEV PC install just the FIRST link to integrate into Visual Studio, all others are for redist packaging only, DO NOT install them on your DEV PC.

CR will not save passwords in the RPT files, never has and never will, using a File DSN is risky for that reason, anyone can see the password you use if they get the file.

In the properties of the viewer there is another option to ReuseParameterValueOnRefresh, make sure that option is set to false, or set it in code.

And don't use Report.Refresh(), it will use the default parameter values.

Like Brian indicated, set the log on info in your app also. See KBA 2281780 for a C# sample on the various log on methods.


10 |10000 characters needed characters left characters exceeded