cancel
Showing results for 
Search instead for 
Did you mean: 

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

Former Member
0 Kudos

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)
        {
            
            Controls.Add(Menu());
            CrystalReportViewer tempViewer = new CrystalReportViewer();
            ReportDocument tempCover = new ReportDocument();
            tempCover.Load(file);
           // 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.Refresh();
            //tempViewer.RefreshReport();
            tempViewer.Location = new Point(1325, 27);
            tempViewer.AutoSize = true;
            Controls.Add(tempViewer);
           
}

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: 13.0.18.2192

SAP Crystal reports, version for VS 13.0.17.2096

Regards,

Neel

former_member292966
Active Contributor
0 Kudos

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,

Brian

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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.

Regards,

Neel

Answers (3)

Answers (3)

Former Member
0 Kudos

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.

Regards,

Neel

0 Kudos

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:

https://wiki.scn.sap.com/wiki/display/BOBJ/Crystal+Reports%2C+Developer+for+Visual+Studio+Downloads

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.

Don

Former Member
0 Kudos

Brian,

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.

Regards,

Neel