IndexOutOfRangeException

IndexOutOfRangeException

Forum member · Jul 14, 2015
I have a pretty simple report/subreport with 2 queries. The report takes 3 parameters. I have verified the queries will return data from the database when the parameter values are legitimate. However, when calling the Run method, I get an IndexOutRangeException. I don't see anything in the stack trace or error message that gives any clues as to where the error is. I can only assume it's the Parameters dictionary, since that's the only collection I have associated with the document. Code is below: namespace ReportProto1 { class Program { static void Main(string[] args) { var connectionString = @"Data Source=em6w39u7nt.database.windows.net;Initial Catalog=DeviceCloud.DB;Persist Security Info=True;User ID=*******;Password=*********;MultipleActiveResultSets=True;Encrypt=True"; DateTime startDate; DateTime endDate; if (DateTime.TryParse("06/01/2015", out startDate) && DateTime.TryParse("06/30/2015", out endDate)) { var reportDoc = new DocumentLayout(@"C:Temp\Standard_Report.dplx"); var reportParms = new ParameterDictionary(); reportParms.Add("RequestedBy", "Russell de Pina"); reportParms.Add("RequestDate", DateTime.Now.ToString("yyyy-MMM-dd")); reportParms.Add("SerialNumber", "100000002"); reportParms.Add("StartDate", startDate.ToShortDateString()); reportParms.Add("EndDate", endDate.ToShortDateString()); var doc = reportDoc.Run(reportParms); doc.Draw(@"C:\Temp\reportTest.pdf"); } } } }

Re: IndexOutOfRangeException

Support · Jul 15, 2015
Hello, After reviewing the dplx file it has been found that the IndexOutRangeException was caused due to incorrectly referencing the parameters and field names in the Record Box and Record Area controls. Correct way to reference report parameters for display on the report is as follows: In Record Box: Parameters["SerialNumber"] In Record Area: #Parameters["SerialNumber"]# The query fields from the report query should be referenced as follows: In Record Box: DeviceDescription In Record Area: #DeviceDescription# Thanks, ceTe Software support Team.