drowned
drowned

Reputation: 550

data source for report viewer control in WPF

I have a ReportViewer control in a WindowsFormsHost tag in my WPF application. When I use this code:

    rptViewer1.LocalReport.ReportPath = ...

    List<ReportParameter> parms = new List<ReportParameter>();
    parms.Add(new ReportParameter("regionID", "01"));
    rptViewer1.LocalReport.SetParameters(parms);

    rptViewer1.RefreshReport();

I get an error about a data source instance not being supplied. I can run the stored procedure manually and then use it to populate a datasource object, like...

var dt = DAL.GetData()
var rds = new ReportDataSource("DataSet1", dt);
rptViewer1.LocalReport.DataSources.Add(rds);

And this will cause the report to display, but then I am passing in my parameters to the GetData() method rather than to the report; this doesn't seem right. In my SSRS project, I am using a shared datasource, and it allows me to pass in the parameters on the report front end as I would expect. What am I doing wrong?

Upvotes: 2

Views: 1247

Answers (1)

jklemmack
jklemmack

Reputation: 3636

If you are using ProcessingMode = Local, then YOU are responsible for large portions of teh report. You or your application defined which parameters there are, how data is loaded, & what sub-report or drill through events do. You must explicitly code these. If the ProcessingMode = Remote, then all of these elements are handled by the reporting server. Microsoft doesn't spell this out very clearly in MSDN, but I can see their justification being "if you are going to host the report in your app, then you can be responsible for all the details".

Upvotes: 1

Related Questions