Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

One or more parameters required to run the report have not been specified

I'm trying to print a RDLC file directly without showing Microsoft Report Viewer, I have followed the MSDN's example but now, every time I call the "Render" method of my instance of LocalReport class it throws the "One or more parameters required to run the report have not been specified." exception.

Can anyone tell me which parameter is required that I missed? or how can I find more detail about this exception?

        LocalReport report = new LocalReport();
        report.ReportPath = System.Windows.Forms.Application.StartupPath + "\\" + rdlcFileName;
        report.EnableExternalImages = true;

        ReportParameter[] reportParams = new ReportParameter[]
        {
            new ReportParameter("LogoAddress", settings.LogoFileName),
            new ReportParameter("FooterValue", settings.InvoicesFooter)
        };
        report.SetParameters(reportParams);

        report.DataSources.Add(new ReportDataSource("Invoice", new PrintableInvoice[] { invoice }));
        report.DataSources.Add(new ReportDataSource("InvoiceItem", invoiceItems));

        Warning[] warnings;
        try
        {
            string deviceInfo =
                "<DeviceInfo>" +
                "  <OutputFormat>EMF</OutputFormat>" +
                "  <PageWidth>8.5in</PageWidth>" +
                "  <PageHeight>11in</PageHeight>" +
                "  <MarginTop>0.25in</MarginTop>" +
                "  <MarginLeft>0.25in</MarginLeft>" +
                "  <MarginRight>0.25in</MarginRight>" +
                "  <MarginBottom>0.25in</MarginBottom>" +
                "</DeviceInfo>";

            m_streams = new List<Stream>();
            report.Render("Image", deviceInfo, _CreateStream, out warnings);

            foreach( Stream stream in m_streams )
                stream.Position = 0;
        }
        catch( Exception ex )
        {
            System.Diagnostics.Debug.WriteLine(ex.Message);
        }

and the _CreateStream is:

    private Stream _CreateStream(string name, string fileNameExtension, Encoding encoding, string mimeType, bool willSeek)
    {
        Stream stream = new FileStream(name + "." + fileNameExtension, FileMode.Create);
        m_streams.Add(stream);
        return stream;
    }
like image 392
mrtaikandi Avatar asked Nov 19 '08 11:11

mrtaikandi


People also ask

What are the parameters of report writing?

Parameters are one of the built-in collections that you can include in an expression in a report. Because expressions are used to define values throughout a report definition, you can use parameters to control report appearance or to pass values to related subreports or reports that also use parameters.

How do I add a parameter in report Builder?

To add or edit a report parameter In Report Builder or Report Designer in SQL Server Data Tools (SSDT), in the Report Data pane, right-click the Parameters node and click Add Parameter. The Report Parameter Properties dialog box opens. In Name, type the name of the parameter or accept the default name.

What does report parameters mean?

Report parameters determine what information is included in the report and how that information is displayed.


1 Answers

i just discovered if you pass parameter value as empty string like parameter = "" it will give you that error

took me a while

like image 150
Gerrie Pretorius Avatar answered Sep 21 '22 15:09

Gerrie Pretorius