Print Page | Close Window

Load Report Failed when Applying Current Values

Printed From: Crystal Reports Book
Category: Crystal Reports for Visual Studio 2005 and Newer
Forum Name: Writing Code
Forum Discription: .NET programming API, report integration
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=4717
Printed Date: 03 May 2025 at 9:47pm


Topic: Load Report Failed when Applying Current Values
Posted By: cipheris
Subject: Load Report Failed when Applying Current Values
Date Posted: 04 Nov 2008 at 7:08am
Below is a copy of my code.  I am receiving a Load Report Failed at crReport.DataDefinition.ParameterFields[0].ApplyCurrentValues(values0);
 
Any ideas?
 
 
CrystalDecisions.Shared.ParameterDiscreteValue pdv = new CrystalDecisions.Shared.ParameterDiscreteValue();

CrystalDecisions.CrystalReports.Engine.ReportDocument crReport = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

crReport.FileName = "Report1.rpt"; ;

crReport.Load(@"C:\Apps\Web\TestCFML\" + crReport.FileName, OpenReportMethod.OpenReportByDefault);

//this.CrystalReportViewer1.ReportSource = Server.MapPath("report1.rpt");

this.CrystalReportViewer1.ReportSource = @"C:\Apps\Web\TestCFML\" + crReport.FileName;

ParameterValues values0 = new ParameterValues();

pdv.Value = "MIA";

values0.Add(pdv);

crReport.DataDefinition.ParameterFields[0].ApplyCurrentValues(values0);

ParameterValues values1 = new ParameterValues();

pdv.Value = DateTime.Now.AddDays(-6);

values1.Add(pdv);

crReport.DataDefinition.ParameterFields[1].ApplyCurrentValues(values1);

ParameterValues values2 = new ParameterValues();

pdv.Value = DateTime.Now;

values2.Add(pdv);

crReport.DataDefinition.ParameterFields[2].ApplyCurrentValues(values2);

ParameterValues values3 = new ParameterValues();

pdv.Value = "TEST";

values3.Add(pdv);

crReport.DataDefinition.ParameterFields[3].ApplyCurrentValues(values3);



-------------
carlos



Replies:
Posted By: cipheris
Date Posted: 04 Nov 2008 at 10:05am
This line is actually not in the code: 
crReport.Load(@"C:\Apps\Web\TestCFML\" + crReport.FileName, OpenReportMethod.OpenReportByDefault);
 
I added this to see if it would resolve the issue.  It did not.



-------------
carlos


Posted By: cipheris
Date Posted: 04 Nov 2008 at 11:38am
I resolved the Load Report Probem.  Now I am having issues displaying the reports with the parameters.  Any ideas?  Below is how I resolved the Load Report Issue.
 

CrystalDecisions.Shared.ParameterDiscreteValue pdv = new CrystalDecisions.Shared.ParameterDiscreteValue();

CrystalDecisions.CrystalReports.Engine.ReportDocument crReport = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

crReport.FileName = Server.MapPath("Report1.rpt");

ParameterValues values0 = new ParameterValues();

pdv.Value = "MIA";

values0.Add(pdv);

crReport.DataDefinition.ParameterFields[0].ApplyCurrentValues(values0);

ParameterValues values1 = new ParameterValues();

pdv.Value = DateTime.Now.AddDays(-6);

values1.Add(pdv);

crReport.DataDefinition.ParameterFields[1].ApplyCurrentValues(values1);

ParameterValues values2 = new ParameterValues();

pdv.Value = DateTime.Now;

values2.Add(pdv);

crReport.DataDefinition.ParameterFields[2].ApplyCurrentValues(values2);

ParameterValues values3 = new ParameterValues();

pdv.Value = "TEST";

values3.Add(pdv);

crReport.DataDefinition.ParameterFields[3].ApplyCurrentValues(values3);

this.CrystalReportViewer1.ReportSource = crReport;



-------------
carlos


Posted By: cipheris
Date Posted: 04 Nov 2008 at 12:06pm
The above code solved my issues.

-------------
carlos



Print Page | Close Window