[英]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數據集,以查看實際將數據推送到報表中的方式。
請,這對我來說很奇怪。所以我解決了這個問題,並通過刪除數據集並再次將其重新添加到我的報告中來解決它,因此基本上我刪除了數據集並添加了相同的數據集,現在正在工作..
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.