I've taken an example ( link ) 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 the ReportView with the parameters works, but when I add the function generate PDF, it generates error saying that the parameter was not passed.
Follow 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");