Skip to Content
0
Former Member
Sep 30, 2015 at 06:10 PM

ReportDocument.Refresh() causes "Missing values parameters" exception

204 Views

Hello Everyone,

I hit a wall while trying to output a crystal report in PDF format. After the report is loaded, I want to use the refresh method of the ReportDocument object so that the report can show the most update data then export it in PDF. But what I had been experiencing is that whenever I used the Refresh method the code always throws an exception in the line where the report needs to be exported in PDF format. When I don't use the Refresh method, the code doesn't break in the line where it has to export the document in PDF. I would like to know what alternative there could be. Because the code does what it was intended, which is connect to a database, run a stored procedure and then output the Crystal in PDF. It is just that the data shown is not up to date.

Any help would be truly appreciated.

Here the code:

ArrayList ParameterArrayList = new ArrayList(); //Report parameter list. Needs to be declared even if no parameters is being passed to the report

CrystalReportBase objReportBase = new CrystalReportBase(); //this is custom class that loads a crystal report, connect to a datasource, pass parameters to a report, and return a a return ReportDocument object

ReportDocument objReportDocument = new ReportDocument(); //Report document

try

{

string filterExtension = "*.rpt";

string substringInFileName = "M1_2_PhoneAnswerPerformance";

/*The report with two parameters. */

ParameterArrayList.Add(0);

ParameterArrayList.Add("No"); //Parameter 1 with input 1.

//ParameterArrayList.Add(1);

//ParameterArrayList.Add("1"); //Parameter 2 with input 1.

//retrieve connection information from the web2 connection string

objReportBase.ServerName = serverConnectionInfo.DataSource;

objReportBase.UserID = serverConnectionInfo.UserID;

objReportBase.Password = serverConnectionInfo.Password;

List<ReportFile> reportFiles = Utilities.GetFilesFromDirectory(@crystalPhoneReportPerformancePath, filterExtension, substringInFileName).ToList();

foreach (ReportFile reportFile in reportFiles)

{

objReportDocument = objReportBase.GenerateReport(reportFile.FileName, ParameterArrayList, crystalPhoneReportPerformancePath);

objReportDocument.Refresh(); Using this line causes....

//Save output report

objReportDocument.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, string.Format("{0}{1}{2}", @crystalPhoneReportOutputMemberServicesPath, Path.GetFileNameWithoutExtension(reportFile.FileName), ".pdf")); ...the code to break in this line

//Export this file in Excel format as well

if (reportFile.FileName.Contains("CLHS_M1_2_PhoneAnswerPerformanceGraphs_Combined"))

{

objReportDocument.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.ExcelWorkbook, string.Format("{0}{1}{2}", @crystalPhoneReportOutputMemberServicesPath, Path.GetFileNameWithoutExtension(reportFile.FileName), ".xls"));

}

}

//release those resources

objReportDocument.Dispose();

objReportDocument.Close();

objReportDocument = null;

catch{