table 上的报告查看器#Error

Report Viewer #Error on table

你好

有谁知道如何找到为什么我的报告中有#error 而不是数据?直到今天,该报告都运行良好,我没有对代码进行任何更改,现在我得到了这个#error 东西。我如何调试它并查看它的原因在哪里?我已经调试了我的代码,我没有发现任何异常。我用来加载报告的代码是:

public static bool LoadSurveillanceDataInReport(ref ReportViewer rpt, DateTime dStart, DateTime dEnd, double kilometersDroven)
        {
            try
            {
                reportPath = @"C:\MSRDS4\bin\Reports\SurveillanceReport.rdlc";
                pdfName = "Surveillance_Report_" + dStart.ToShortDateString().Replace('/', '_').Replace('-', '_');

                bool hasDetections = false;
                bool hasTaken = false;

                //Get Surveillance data
                IList<ClsSurveillanceTasks> surveillanceTasks = GetTaskData(dStart.Date.ToString("yyyy-MM-dd"), dEnd.Date.ToString("yyyy-MM-dd"));
                if (surveillanceTasks == null)
                    return false;
                else if (surveillanceTasks.Count > 0)
                    hasTaken = true;


                IList<ClsSurveillanceDetections> surveillanceDetection = GetDetectionData(dStart.Date.ToString("yyyy-MM-dd"), dEnd.Date.ToString("yyyy-MM-dd"));
                if (surveillanceDetection == null)
                    return false;
                else if (surveillanceDetection.Count > 0)
                    hasDetections = true;

                IList<ClsSurveillanceRobotStatus> surveillanceRobotStatus = GetRobotStatusData(dStart.Date.ToString("yyyy-MM-dd"), dEnd.Date.ToString("yyyy-MM-dd"), kilometersDroven);
                if (surveillanceRobotStatus == null)
                    return false;

                //reset report
                rpt.Reset();
                rpt.LocalReport.DataSources.Clear();

                //set dataset
                var rDSTasks = new ReportDataSource { Value = surveillanceTasks, Name = "dsTasks" };
                rpt.LocalReport.DataSources.Add(rDSTasks);

                var rDSDetections = new ReportDataSource { Value = surveillanceDetection, Name = "dsDetections" };
                rpt.LocalReport.DataSources.Add(rDSDetections);

                var rDSRobotStatus = new ReportDataSource { Value = surveillanceRobotStatus, Name = "dsRobotStatus" };
                rpt.LocalReport.DataSources.Add(rDSRobotStatus);

                //Set report path
                rpt.LocalReport.ReportPath = reportPath;

                //Parameters
                var reportDate = dStart.Date;
                var monthName = new DateTime(reportDate.Date.Year, reportDate.Date.Month, reportDate.Date.Day).ToString("MMM", System.Globalization.CultureInfo.InvariantCulture);

                var formatedDate = reportDate.Date.Day + " " + monthName + " " + reportDate.Date.Year;
                var rptParams = new ReportParameter[] { 
                new ReportParameter("nowDate", formatedDate),
                new ReportParameter("Company", company), 
                new ReportParameter("Adres", adres), 
                new ReportParameter("Postcode", postcode), 
                new ReportParameter("Place", place), 
                new ReportParameter("hasDetections", hasDetections.ToString()), 
                new ReportParameter("hasTaken", hasTaken.ToString())
                };

                rpt.LocalReport.SetParameters(rptParams);

                try
                {
                    //Set page Settings to prevent big margins
                    var pg = new System.Drawing.Printing.PageSettings
                    {
                        Margins = { Top = 16, Bottom = 16, Left = 16, Right = 16 }
                    };

                    rpt.SetPageSettings(pg);
                }
                catch (Exception ex)
                {
                    LogHandler(ex);
                }

                return true;
            }
            catch (Exception ex)
            {
                LogHandler(ex);
                return false;
            }
        }

GetTaskData 正在返回数据,其中没有空值。

任何帮助将不胜感激!谢谢

这本身就是一个 RDLC 错误。它正在尝试解析您的日期,但没有成功。这是由于您尝试在报告中打印的错误日期造成的。 您可以使用多个日期进行调试。

首先在 .NET 消息中打印 formatedDate(或使用 .net 调试器检索它)。同时删除报告中日期字段的所有格式。只需将变量转储到报告中即可。格式错误可能是问题所在。

顺便说一句,调试 rdlc 很烦人。如果您没有想法,您应该检查 xml-数据集,看看您实际以何种方式将数据推送到您的报告。

拜托,这对我来说太奇怪了。所以我解决了这个问题,我通过删除数据集并将其重新添加到我的报告中来解决它,所以基本上我删除了数据集并添加了相同的数据集,现在它正在工作..