on 02-07-2017 9:32 PM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.