none
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 += newSubreportProcessingEventHandler(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<objectobject> pageSettings = new Dictionary<objectobject>();

                        Print(reportPageSettings, pageSettings, printJob);

                        //Query the printer for the status

                        using (var ops = newPanther.Business.Printing.PrintingOps("PantherPrinting"newConnectionsInfo("PantherPrinting"))) {

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

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

                            }

                        }

                    }

                }

            }
    Tuesday, April 2, 2019 3:38 PM