Skip to Content
0
Former Member
Nov 21, 2017 at 11:56 PM

Crystal Reports Not Accepting Parameters From Visual Studio 2015 Program

93 Views Last edit Nov 22, 2017 at 03:25 PM 2 rev

I just upgraded my application from Visual Studio 2005 to Visual Studio 2015 and I use Crystal Reports within my program to run my reports. The problem is when I run the reports from my application in VS2015, it gives me every record in the database. When I run in VS2005, it would give me only the records that matched the specified criteria. It has been working fine for several years in VS2005.

In my code, I do the following:

<code>Reports.crDailyProductionByCsr myRpt =newReports.crDailyProductionByCsr();<br>
ConfigureCrystalReports(myRpt);
InitReportParameters();// Initialize the report parameter fields
AssignReportValue(@"CompanyName","Company Name");
AssignReportValue(@"ReportTitle","Daily Production ");
AssignReportValue(@"DefaultNullValue",'2000-01-01');
AssignReportValue(@"CSRId",CSRId);// Move the Parameters to the report
SetReportParameters();
DisplayReport(myRpt);

// SetReportParameters takes the ReportField values from the program and
// moves them to myPFields for Crystal Reports. I have verified the values
// are correctly filled into ReportField from the AssignReportValue methods
// above.
privatevoidSetReportParameters(){

for(int i =0; i <UsedReportFieldCount; i++) {
myPField[i].ParameterFieldName=ReportField[i];
myDValue[i].Value=ReportFieldValue[i];
myPField[i].CurrentValues.Add(myDValue[i]);
myPFields.Add(myPField[i]);
}
}

privatevoidDisplayReport(ReportDocument myRptDoc)
crvViewer.BackColor=System.Drawing.SystemColors.Control;
crvViewer.ParameterFieldInfo= myPFields;// ParameterField[]
crvViewer.ToolPanelView=CrystalDecisions.Windows.Forms.ToolPanelViewType.None;
crvViewer.ReportSource= myRptDoc; crvViewer.Zoom(90);
}

When I run this in the viewer in Visual Studio 2015, I get the expected results fine. But when I run from my program, it returns all daily production records in the whole database concluding that for some reason the code is not passing the parameter values correctly to the report.