嗨,我在c#中使用报表查看器进行打印,同一rdlc用于具有不同参数的两个打印,当使用 StampaMarcaTempo 打印为true时,出现以下错误,它是什么?以及如何解决?
错误行: ReportDataSource rds = new ReportDataSource(“ DataSet1”,d.Tables [0]);
C#代码:
public void StampaRisorseCantiere(Utente ustampa, string StartData, string EndData, string Ore, Boolean StampaTutteLeRisorse, Boolean StampaMarcaTempo)
{
try
{
DataStampaRisorse d = new DataStampaRisorse();
d = RisorseUmaneModel.DataStampaRisorseUmane(ustampa.IdUtente, StartData, EndData, StampaTutteLeRisorse);
if (StampaMarcaTempo)
{
MarcaTempo mt = new MarcaTempo(ustampa);
DataTable dt = mt.CaricaDataeTotaleOre(StartData, EndData);
Console.WriteLine("Numero di colonne: " + dt.Columns.Count);
dt.Columns["Data"].ColumnName = "DataINS";
//d.Clear();
d = dt.DataSet as DataStampaRisorse;
}
ReportDataSource rds = new ReportDataSource("DataSet1", d.Tables[0]);
//this.r.LocalReport.EnableExternalImages = true;
this.r.LocalReport.DataSources.Clear();
this.r.LocalReport.DataSources.Add(rds);
ReportParameterCollection reportParameters = new ReportParameterCollection
{
new ReportParameter("NomeRisorsa", "Risorsa " + ustampa.GetNome() ?? "")
};
ReportParameterCollection reportParameters2 = new ReportParameterCollection
{
new ReportParameter("Ore", " " + Ore ?? "")
};
this.r.LocalReport.SetParameters(new ReportParameter("Stampatuttelerisorse", "" + StampaTutteLeRisorse));
this.r.LocalReport.SetParameters(new ReportParameter("StampaMarcaTempo", "" + StampaMarcaTempo));
this.r.LocalReport.SetParameters(reportParameters);
this.r.LocalReport.SetParameters(reportParameters2);
this.r.LocalReport.Refresh();
this.r.RefreshReport();
this.r.SetDisplayMode(DisplayMode.PrintLayout);
}
catch (Exception ex)
{
Managementerror.SendError("Errore Stampa Risorse Cantiere: " + ex);
}
}