locked
Unable to get parameter value from .rdlc at runtime RRS feed

  • Question

  • Hello community, I have a issue in which I am unable to get a parameters value nor sqlvalue from a rdlc file at runtime.  I loop over the Parameter list in each dataset and add the name and value.  Except I do not get the value.  Below is my code snippet.

    public void PrintSSRSReport(PrintJob printJob) {

                printJob.Warnings = new List<string>();

                string reportFileName = printJob.ReportPath + "\\" + printJob.ReportFileName;

                //Load a class representing properties of the report that we can't read from the SSRS report object

                SsrsReportClass reportClass = new SsrsReportClass(reportFileName);

                //Set properties of the report object

                using (LocalReport report = new LocalReport { ReportPath = reportFileName }) {

                    report.DataSources.Clear();

                    report.SubreportProcessing += new SubreportProcessingEventHandler(SubreportProcessingEventHandler);

                    report.EnableExternalImages = true;

                    SetReportParameters(report, printJob);

                    PopulateReportDatasets(reportClass, printJob);

                    foreach (var dataSet in reportClass.DataSets) {

                        var parameterList = new List<string>();

                        foreach (var parameter in dataSet.Parameters) {

                            parameterList.Add($"{parameter.ParameterName} = {parameter.SqlValue}");

                        }

                        printJob.ReportDataSets.Add(

                            new ReportDataSet {

                                Name = dataSet.DataSetName,

                                Procedure = dataSet.CommandText,

                                DataSetParameters = parameterList,

                                ConnectionString = dataSet.ConnectionString

                            }

                        );

                        ReportDataSource reportDataSource = GetReportDatasource(dataSet);

                        report.DataSources.Add(reportDataSource);

                        //Add to the module-level variable to all subreports to access

                        mLabelData.Add(reportDataSource);

                    }

                    report.Refresh();

                    // Get the page settings from the report

                    var reportPageSettings = report.GetDefaultPageSettings();

                    mTopMargin = reportPageSettings.Margins.Top;

                    mBottomMargin = reportPageSettings.Margins.Bottom;

                    mLeftMargin = reportPageSettings.Margins.Left;

                    mRightMargin = reportPageSettings.Margins.Right;

                    mIsLandscape = reportPageSettings.IsLandscape;

                    var showInBrowser = !printJob.DirectToPrinter;

                    if (printJob.PrintToPdf || showInBrowser) {

                        printJob._bytes = PrintToPdf(report, printJob, showInBrowser);

                    }

                    else if (printJob.DirectToPrinter) {

                        Export(report, printJob);

                        Dictionary<object, object> pageSettings = new Dictionary<object, object>();

                        Print(reportPageSettings, pageSettings, printJob);

                        //Query the printer for the status

                        using (var ops = new Panther.Business.Printing.PrintingOps("PantherPrinting", new ConnectionsInfo("PantherPrinting"))) {

                            if (ops.IsPrinterErrored(printJob.PrinterName)) {

                                throw new Exception($"Printer {printJob.PrinterName} is in error state");

                            }

                        }

                    }

                }

            }

      
    Monday, April 1, 2019 11:55 PM

All replies

  • Hi synchronize,

    Thank you for posting here.

    For your question is more related to RDLC report, you could post a new thread in Visual Studio Report Controls forum.

    Best Regards,

    Wendy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, April 2, 2019 8:36 AM