Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SSRS Report problem in wpf

DataTable reportData = this.GetReportData(startId, endId, empId, minAmount, reportType);


                ReportViewer reportViewer = new ReportViewer();
                reportViewer.ProcessingMode = ProcessingMode.Local;

                reportViewer.LocalReport.ReportEmbeddedResource = "PDCL.ERP.Modules.Marketing.Reports.rptDoctorDetail.rdlc";  

                ReportDataSource ds = new ReportDataSource();
                ds.Name = "DoctorDetail_Report";
                ds.Value = reportData;
                reportViewer.LocalReport.DataSources.Add(ds);


                reportViewer.RefreshReport();
                this.WindowsFrmHost.Child = reportViewer;

this is my code.I'm using SSRS but the viewer only shows but not any data. Why..?

like image 637
Johnny Avatar asked Nov 14 '22 10:11

Johnny


1 Answers

I think you need to call refresh report after the reportviewer is loaded into the view.

Here is my code which works (reportViewerHost is WindowsFormsHost, declared in UserControl using XAML)

private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            SqlReportViewModel report = (SqlReportViewModel)this.DataContext;
            Microsoft.Reporting.WinForms.ReportViewer reportviewer = new Microsoft.Reporting.WinForms.ReportViewer();
            reportViewerHost.Child = reportviewer;
            reportviewer.ProcessingMode = Microsoft.Reporting.WinForms.ProcessingMode.Local;
            reportviewer.LocalReport.ReportPath = report.FileName;
            report.LoadReport(reportviewer.LocalReport);
            reportviewer.RefreshReport();
        }

in the LoadReport Method of the SqlReportViewModel, I am setting the datasource as

_report.DataSources.Add(new ReportDataSource(dataset.Name, tbl));

where _report is the reference to LocalReport object passed as an argument

LocalReport _report;

It took me a while to figure this out... hope this helps.. Good Luck..:)

like image 98
Bhuvan Avatar answered Dec 24 '22 08:12

Bhuvan