Hi i am really new to C#
can anyone please give a step by step guide on how can i find out which parameter in the RDLC report is causing an error. I have 123 parameters. and its giving me error on rendering.
I have tried the last 2 days....
error:
Microsoft.Reporting.WinForms.LocalProcessingException: An error occurred during local report processing. ---> Microsoft.ReportingServices.ReportProcessing.ReportProcessingException: One or more parameters required to run the report have not been specified.
at Microsoft.ReportingServices.ReportProcessing.Execution.RenderReport.ValidateReportParameters()
at Microsoft.ReportingServices.ReportProcessing.Execution.RenderReportOdpInitial.PrepareForExecution()
at Microsoft.ReportingServices.ReportProcessing.Execution.RenderReport.Execute(IRenderingExtension newRenderer)
at Microsoft.ReportingServices.ReportProcessing.ReportProcessing.RenderReport(IRenderingExtension newRenderer, DateTime executionTimeStamp, ProcessingContext pc, RenderingContext rc, IChunkFactory yukonCompiledDefinition)
at Microsoft.Reporting.LocalService.CreateSnapshotAndRender(ReportProcessing repProc, IRenderingExtension renderer, ProcessingContext pc, RenderingContext rc, SubreportCallbackHandler subreportHandler, ParameterInfoCollection parameters, DatasourceCredentialsCollection credentials)
at Microsoft.Reporting.LocalService.Render(String format, String deviceInfo, String paginationMode, Boolean allowInternalRenderers, IEnumerable dataSources, CreateAndRegisterStream createStreamCallback)
at Microsoft.Reporting.WinForms.LocalReport.InternalRender(String format, Boolean allowInternalRenderers, String deviceInfo, PageCountMode pageCountMode, CreateAndRegisterStream createStreamCallback, Warning[]& warnings)
--- End of inner exception stack trace ---
at Microsoft.Reporting.WinForms.LocalReport.InternalRender(String format, Boolean allowInternalRenderers, String deviceInfo, PageCountMode pageCountMode, CreateAndRegisterStream createStreamCallback, Warning[]& warnings)
at Microsoft.Reporting.WinForms.LocalReport.InternalRender(String format, Boolean allowInternalRenderers, String deviceInfo, PageCountMode pageCountMode, String& mimeType, String& encoding, String& fileNameExtension, String[]& streams, Warning[]& warnings)
at Microsoft.Reporting.WinForms.LocalReport.Render(String format, String deviceInfo, PageCountMode pageCountMode, String& mimeType, String& encoding, String& fileNameExtension, String[]& streams, Warning[]& warnings)
at BufferManPowerReport.Form1.ExportToPDF() in N:\ED\BufferProductionReports\BufferManPower\BufferManPowerReport\BufferManPowerReport\Form1.cs:line 717
What I have tried:
tring strExeFilePath = Assembly.GetExecutingAssembly().Location;
string exeFolder = Path.GetDirectoryName(strExeFilePath);
string reportPath = Path.Combine(exeFolder, "Report1.rdlc");
string Shdate = dateTimePicker1.Value.ToString("M-dd-yyyy");
string Shift = comboBox1.Text;
LocalReport report = new LocalReport();
report.ReportPath = "Report1.rdlc";
DataTable dataTable = GetData();
ReportParameter[] param = new ReportParameter[123];
param[0] = new ReportParameter("RPSHIFT", Shift);
param[1] = new ReportParameter("ReportParameter1", Shdate);
param[2] = new ReportParameter("UL1", LBLUNIT1.Text);
param[3] = new ReportParameter("UL2", LBLUNIT2.Text);
param[4] = new ReportParameter("T1MK", TXTA1MK.Text);
param[5] = new ReportParameter("T1TMP", TXTA1TMP.Text);
param[6] = new ReportParameter("T1TOT", TXTA1SUM.Text);
param[7] = new ReportParameter("T1MOD", TXTA1MD.Text);
param[8] = new ReportParameter("T1VAC", TXTA1VC.Text);
param[9] = new ReportParameter("T1C1", TXTA1CI.Text);
param[10] = new ReportParameter("T1TR", TXTA1TR.Text);
param[11] = new ReportParameter("T1HLP", TXTA1HLP.Text);
param[12] = new ReportParameter("T1UL1", TXTA1U1.Text);
param[13] = new ReportParameter("T1UL2", TXTA1U2.Text);
param[14] = new ReportParameter("T1MPW", TXTA1AMP.Text);
param[15] = new ReportParameter("T1CM", TXTA1NOTE.Text);
param[16] = new ReportParameter("T2MK", TXTA2MK.Text);
param[17] = new ReportParameter("T2TMP", TXTA2TMP.Text);
param[18] = new ReportParameter("T2TOT", TXTA2SUM.Text);
param[19] = new ReportParameter("T2MOD", TXTA2MD.Text);
param[20] = new ReportParameter("T2VC", TXTA2VC.Text);
param[21] = new ReportParameter("T2CI", TXTA2CI.Text);
param[22] = new ReportParameter("T2TR", TXTA2TR.Text);
param[23] = new ReportParameter("T2HLP", TXTA2HLP.Text);
param[24] = new ReportParameter("T2UL1", TXTA2U1.Text);
param[25] = new ReportParameter("T2UL2", TXTA2U2.Text);
param[26] = new ReportParameter("T2MPW", TXTA2AMP.Text);
param[27] = new ReportParameter("T2CM", TXTA2NOTE.Text);
param[28] = new ReportParameter("T3MP", TXTA3MK.Text);
param[29] = new ReportParameter("T3TMP", TXTA3TMP.Text);
param[30] = new ReportParameter("T3TOT", TXTA3SUM.Text);
param[31] = new ReportParameter("T3MOD", TXTA3MD.Text);
param[32] = new ReportParameter("T3VC", TXTA3VC.Text);
param[33] = new ReportParameter("T3CI", TXTA3CI.Text);
param[34] = new ReportParameter("T3TR", TXTA3T3.Text);
param[35] = new ReportParameter("TRHLP", TXTA3HLP.Text);
param[36] = new ReportParameter("T3UL1", TXTA3U1.Text);
param[37] = new ReportParameter("T3UL2", TXTA3U3.Text);
param[38] = new ReportParameter("T3MPW", TXTA3AMP.Text);
param[39] = new ReportParameter("T3COM", TXTA3NOTE.Text);
param[40] = new ReportParameter("T4MK", TXTA4MK.Text);
param[41] = new ReportParameter("T4TMP", TXTA4TMP.Text);
param[42] = new ReportParameter("T4TOT", TXTA4SUM.Text);
param[43] = new ReportParameter("T4MD", TXT4MD.Text);
param[44] = new ReportParameter("T4VC", TXTA4VC.Text);
param[45] = new ReportParameter("T4CI", TXTA4CI.Text);
param[46] = new ReportParameter("T4TR", TXTA4TR.Text);
param[47] = new ReportParameter("T4HLP", TXTA4HLP.Text);
param[48] = new ReportParameter("T4U1", TXTA4U1.Text);
param[49] = new ReportParameter("T4U2", TXTA4U2.Text);
param[50] = new ReportParameter("T4WMP", TXTA4AMP.Text);
param[51] = new ReportParameter("T4CM", TXTA4NOTE.Text);
param[52] = new ReportParameter("TDMK", TXTDMK.Text);
param[53] = new ReportParameter("TDTMP", TXTDTMP.Text);
param[54] = new ReportParameter("TDTOT", TXTDSUM.Text);
param[55] = new ReportParameter("TDMD", TXTDMD.Text);
param[56] = new ReportParameter("TDVC", TXTDVC.Text);
param[57] = new ReportParameter("TDCI", TATDCI.Text);
param[58] = new ReportParameter("TDTR", TXTDTR.Text);
param[59] = new ReportParameter("TDHLP", TXTDHLP.Text);
param[60] = new ReportParameter("TDUL1", TXTDU1.Text);
param[61] = new ReportParameter("TDUL2", TXTDU2.Text);
param[62] = new ReportParameter("RDMPW", TXTDAMP.Text);
param[63] = new ReportParameter("TDCM", TXTDNOTE.Text);
param[64] = new ReportParameter("T6MK", TXTA6MK.Text);
param[65] = new ReportParameter("T6TMP", TXTA6TMP.Text);
param[66] = new ReportParameter("T6TOT", TXTA6SUM.Text);
param[67] = new ReportParameter("T6MD", TXTA6MD.Text);
param[68] = new ReportParameter("T6VC", TXTA6VC.Text);
param[69] = new ReportParameter("T6CI", TXTA6CI.Text);
param[70] = new ReportParameter("T6TR", TXTA6TR.Text);
param[71] = new ReportParameter("T6HLP", TXTA6HLP.Text);
param[72] = new ReportParameter("T6UL1", TXTA6U1.Text);
param[73] = new ReportParameter("T6UL2", TXTA6U2.Text);
param[74] = new ReportParameter("T6MPW", TXTA6AMP.Text);
param[75] = new ReportParameter("T6COM", TXTA6NOTE.Text);
param[76] = new ReportParameter("PWMK", TXPWMK.Text);
param[77] = new ReportParameter("PWTMP", TXPWTMP.Text);
param[78] = new ReportParameter("PWTOT", TXPWSUM.Text);
param[79] = new ReportParameter("PWMD", TXPWMD.Text);
param[80] = new ReportParameter("PWVC", TXPWVC.Text);
param[81] = new ReportParameter("PWCI", TXPWCI.Text);
param[82] = new ReportParameter("PWTR", TXPWTR.Text);
param[83] = new ReportParameter("PWHLP", TXPWHLP.Text);
param[84] = new ReportParameter("PWUL1", TXPWU1.Text);
param[85] = new ReportParameter("PWUL2", TXPWU2.Text);
param[86] = new ReportParameter("PWMPW", TXPWAMP.Text);
param[87] = new ReportParameter("PWCOM", TXPWNOTE.Text);
param[88] = new ReportParameter("PCMK", TXPCMK.Text);
param[89] = new ReportParameter("PCTMP", TXPRCTMP.Text);
param[90] = new ReportParameter("PCTOT", TXPRCSUM.Text);
param[91] = new ReportParameter("PCMD", TXPCMD.Text);
param[92] = new ReportParameter("PCVC", TXPCVC.Text);
param[93] = new ReportParameter("PCCI", TXPCCI.Text);
param[94] = new ReportParameter("PCTR", TXPCTR.Text);
param[95] = new ReportParameter("PCHLP", TXPCHLP.Text);
param[96] = new ReportParameter("PCUL1", TXPCU1.Text);
param[97] = new ReportParameter("PCUL2", TXPCU2.Text);
param[98] = new ReportParameter("PCMPW", TXPCAMP.Text);
param[99] = new ReportParameter("PCCOM", TXPCNOTE.Text);
param[100] = new ReportParameter("TTMP", TXMKTOT.Text);
param[101] = new ReportParameter("TTTMP", TXTMPTOT.Text);
param[102] = new ReportParameter("TTTOT", TXTTOTALS.Text);
param[103] = new ReportParameter("TTMD", TXMDTOTAL.Text);
param[104] = new ReportParameter("TTABS", TXAWAYTOT.Text);
param[105] = new ReportParameter("TTHLP", TXHLPTOTAL.Text);
param[106] = new ReportParameter("TTUL1", TXU1TOTAL.Text);
param[107] = new ReportParameter("TTUL2", TXU2TOTAL.Text);
param[108] = new ReportParameter("TTMPW", TXAMPTOTAL.Text);
param[109] = new ReportParameter("TA1SP", TXTA1UP.Text);
param[110] = new ReportParameter("TA1BP", TXTA1BUP.Text);
param[111] = new ReportParameter("TA2P", TXTA2UP.Text);
param[112] = new ReportParameter("TA3P", TXTA3UP.Text);
param[113] = new ReportParameter("TA4P", TXTA4UP.Text);
param[114] = new ReportParameter("TDP", TXTDUP.Text);
param[115] = new ReportParameter("TA6P", TXTA6UP.Text);
param[116] = new ReportParameter("TA1L", TXTA1UL.Text);
param[117] = new ReportParameter("TA2L", TXTA2UL.Text);
param[118] = new ReportParameter("TA3L", TXTA3UL.Text);
param[119] = new ReportParameter("TA4L", TXTA4UL.Text);
param[120] = new ReportParameter("TDL", TXTDUL.Text);
param[121] = new ReportParameter("TA6L", TXTA6UL.Text);
param[122] = new ReportParameter("TTL", TXULTOT.Text);
report.SetParameters(param);
string reportType = "PDF";
PageCountMode pageCountMode = new PageCountMode();
string mimeType;
string encoding;
string fileNameExtension;
Warning[] warnings;
string[] streams;
string deviceInfo = @"<DeviceInfo>
<OutputFormat>PDF</OutputFormat>
<PageWidth>8.5in</PageWidth>
<PageHeight>11in</PageHeight>
<MarginTop>0.5in</MarginTop>
<MarginLeft>1in</MarginLeft>
<MarginRight>1in</MarginRight>
<MarginBottom>0.5in</MarginBottom>
</DeviceInfo>";
try
{
string A = System.Windows.Forms.Application.StartupPath;
byte[] renderedBytes = report.Render(
reportType,
deviceInfo,
pageCountMode,
out mimeType,
out encoding,
out fileNameExtension,
out streams,
out warnings
);
using (FileStream fs = new FileStream($"Report.{fileNameExtension}", FileMode.Create))
{
fs.Write(renderedBytes, 0, renderedBytes.Length);
}
Console.WriteLine("Report rendered and saved to file.");
}
catch (System.Exception ex)
{
MessageBox.Show("Error:" + ex.ToString());
}