Generate PDF Reportview

Asked

Viewed 102 times

0

I took an example (/a/256234/90835) to generate PDF of a report. The Example worked, but I have other reports that need to pass parameters, if I put only to view in Reportview with the parameters works, but when I add the function to generate PDF, it generates error saying that the parameter was not passed.

Follows my code:

            List<ReportParameter> listaParametro = new List<ReportParameter>();

        listaParametro.Add(new ReportParameter("Matricula", "351"));
        listaParametro.Add(new ReportParameter("Prefixo", "45072"));
        listaParametro.Add(new ReportParameter("SemanaIni", "201750"));

        reportViewer1.ServerReport.SetParameters(listaParametro);

 NetworkCredential myCred = new NetworkCredential("user", "senha");
        reportViewer1.ServerReport.ReportServerCredentials.NetworkCredentials = myCred;

        Warning[] warnings;
        string[] streamids;
        string mimeType;
        string encoding;
        string filenameExtension;

        byte[] bytes = reportViewer1.ServerReport.Render(
            "PDF", null, out mimeType, out encoding, out filenameExtension,
            out streamids, out warnings);

        using (FileStream fs = new FileStream("C:\\Users\\paulo\\Desktop\\Teste_Gera_Relatorio.pdf", FileMode.Create))
        {
            fs.Write(bytes, 0, bytes.Length);
        }

        System.Diagnostics.Process.Start("output.pdf");
  • Which parameter it accuses was not passed?

  • Got @Paulohdsousa, was with some error in VS. I closed and opened again and picked the parameters normally with the code posted.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.