Subreport - Error in the location specification of

2019-07-26 02:29发布

问题:

I'm having the following error that I detail below:

"The 'Encabezado' subreport could not be found at the specified location SPECIFIC ROUTE\ Encabezado.rdlc. Verify that the subreport has been published and that the name is correct."

InitializeComponent();
string nombreSP = "XXX_SP_REPORTING_SERVICES_DESPACHOS";
DataSet ds = frmListClass.ObtenerDS(parametrosXML, nombreSP);
string[] nodoParametro = frmListClass.ParsearParametros(parametrosXML);
int[] cantDecimales = frmListClass.ObtenerCantDecimales(parametrosXML);

ReportParameter p1  = new ReportParameter("Base", nodoParametro[0]);
ReportParameter p2  = new ReportParameter("User", nodoParametro[1]);
ReportParameter p3  = new ReportParameter("Sistema", nodoParametro[3]);
ReportParameter p4  = new ReportParameter("Caratula", nodoParametro[4]);
ReportParameter p5  = new ReportParameter("FormatoQRP", nodoParametro[5]);            
ReportParameter p6  = new ReportParameter("dcmlCant", cantDecimales[0].ToString());
ReportParameter p7  = new ReportParameter("dcmlCantTalle", cantDecimales[1].ToString());
ReportParameter p8  = new ReportParameter("dcmlPrecio", cantDecimales[2].ToString());
ReportParameter p9  = new ReportParameter("dcmlImporte", cantDecimales[3].ToString());



ReportDataSource dataSource = new ReportDataSource(nombreSP, ds.Tables[0]);
this.reportViewer1.LocalReport.DataSources.Clear();
this.reportViewer1.ProcessingMode = ProcessingMode.Local;
string rutaEncabezado = @"D:\\BASCS-ReportingServices\\BAS-ReportingServices\\BCSLDSPT\\Encabezado.rdlc";
string rutaRDLC = @"D:\\BASCS-ReportingServices\\BAS-ReportingServices\\BCSLDSPT\\Report1.rdlc";
Stream subReport = File.OpenRead(rutaEncabezado);
Stream report = File.OpenRead(rutaRDLC);            
this.reportViewer1.LocalReport.LoadReportDefinition(report);
this.reportViewer1.LocalReport.LoadSubreportDefinition("Encabezado", subReport);
this.reportViewer1.LocalReport.SubreportProcessing += new SubreportProcessingEventHandler(AgregarEncabezado);                                                                     
this.reportViewer1.LocalReport.DataSources.Add(dataSource);
this.reportViewer1.LocalReport.SetParameters(new ReportParameter[] { p1, p2, p3, p4, p5, p6, p7, p8, p9/*, p10, p11, p12, p13*/ });
this.reportViewer1.RefreshReport();                        

Warning[] warnings;
string[] streamIds;
string mimeType;
string encoding;
string filenameExtension;
byte[] bytes = reportViewer1.LocalReport.Render("PDF", null, out mimeType, out encoding, out filenameExtension, out streamIds, out warnings);

string rutaArchivo = frmListClass.ObtenerRutaPDF(bytes);
System.Diagnostics.Process.Start(rutaArchivo);


void AgregarEncabezado(object sender, SubreportProcessingEventArgs e)
    {
        string Parametros = "1, 1, NULL, 1";            
        string cadenaConexion = "Data Source=SRVDESARROLLO7\\BASCS; Initial Catalog=bascsreport ;User Id=sa; Password=sa";
        string cadenaComandoSQL = frmListClass.SeteosSQL + frmListClass.SP_Encabezado + " " + Parametros;

        SqlConnection ConexionSQL = new SqlConnection(cadenaConexion);
        ConexionSQL.Open();
        SqlCommand ComandoSQL = new SqlCommand(cadenaComandoSQL, ConexionSQL);
        ComandoSQL.CommandType = CommandType.Text;
        ComandoSQL.Parameters.AddWithValue("@monoemp, @codempusu, @tituloinf, @whereemp", Parametros);
        SqlDataAdapter da = new SqlDataAdapter();
        da.SelectCommand = ComandoSQL;
        DataSet dsEncabezado = new DataSet();
        da.Fill(dsEncabezado, Parametros);
        ConexionSQL.Close();

        ReportDataSource dataSourceEncabezado = new ReportDataSource("XXX_SP_REPORTING_PARAMETROS_EMP", dsEncabezado.Tables[0]);
        e.DataSources.Add(dataSourceEncabezado);

    }

I need to be able to pass to the main report the Subreport (Header), since in it I have parameters that are shown in the Header that are repeated in almost all reports. The subreport is in another project, can this be the problem?

Can the SubreportProcessingEventHandler be ill-defined?

Please I need help!!