ReportingServices Local Mode with CSLA Object as Datas Source

ReportingServices Local Mode with CSLA Object as Datas Source

Old forum URL: forums.lhotka.net/forums/t/7467.aspx


BigPines2 posted on Monday, August 17, 2009

I am working on a CSLA WinForms app which uses ReportingServices local mode. I am using VS2005 as the IDE. I can't get a CSLA ReadOnly collection object to work as the data source in an rdlc report to save my life! I have searched the forum and everyone else seems to be able to get it to work so I am really scratching my head here.

I have tried creating a datasource directly from the BO and also converting the BO to a dataset first and then creating a datasource from that but in both cases, when I try to run the report, the ReportViewer control displays the error: "A data source instance has not been supplied for the data source [Dataset Name]"

The only way I have been able to get this to work is to creat the data source directly from a stored procedure and use the results of hitting the sproc directly as the data source for the report. When I do this, everything works fine so I know the basic code is correct. However, I don't want to have to create a new object just for fetching the report results and then re-fetch this data when it is already available in the collection object!

Naturally, I would prefer to use the CSLA collection directly like this:

        With ReportViewer1
            .ProcessingMode = ProcessingMode.Local

            With .LocalReport
                .ReportEmbeddedResource = "testApplication.testReport.rdlc"
                .DataSources.Add(New ReportDataSource("ProviderList", mCslaList))
            End With

            .RefreshReport()
        End With


I am using Petar Kozul's Active Objects on top od CSLA so that may be what is causing the problem but I don't see why it would. I am going to create a regular CSLA collection next and test if that works.

I have spent almost 10 hours so far trying to figure this out so any help would be greatly appreciated.

Mike

JonnyBee replied on Tuesday, August 18, 2009

Hi,

Download the samples from www.gotreportviewer.com.

Csla objects (both readonlylist and editablelist) work fine with reportviewer.

It would seem that you either have a problem with the DataSource definition and how the list object is supplied to your report.

Another pitfall is to make sure that the datasource must be an IEnumerable. A single object (root) that holds a list can not be your datasource (unless you make it into an IEnumerable that has just one item).

(I am planning to add a couple of reports to the ProjectTracker sample for Csla 3.6.3 for Net 2.0 but that solution requires VisualStudio 2008).

/jonnybee



BigPines2 replied on Tuesday, August 18, 2009

Thanks for the tips Jonny. I have downloaded the object binding example in your link and I am doing everything the same as the example so there must be something wrong with the object itself. I will look into it further and report back with my findings.

Mike

JonnyBee replied on Tuesday, August 18, 2009

Hi,

Just added a reportviewer and ResourceReport to the samples project for "Csla 3.6.3 for .Net 2.0". You must download the code directly from Subversion to get this version. This solution is in C# and requires Visual Studio 2008 (but runs on .Net 2.0) and there is almost no changes in the ReportViewer from VS2005 and code is identical. You should be able to add the ResourceReport WinPart and report definition to an earlier version of the ProjectTracker example project.

Is your datasource named "ProviderList" in the "Report" - "Data Sources" window?
Name must be spelled exacly as shown in this window in order for ReportViewer to find the list of objects.

Another thing you may try is to make sure to clear the datasources list before you add your own:

            With .LocalReport
                .ReportEmbeddedResource = "testApplication.testReport.rdlc"
                .DataSources.Clear()
                .DataSources.Add(New ReportDataSource("ProviderList", mCslaList))
            End With


/jonnybee

BigPines2 replied on Wednesday, August 19, 2009

Ah-HA! You were correct. It was the name in the Data Source window of the report!

I figured that the name provided in DataSources.Add had to match the DATASET or DATATABLE name. Not the name of the Data Source. Makes perfect sense though.

Thanks for the help! :)

Mike

Copyright (c) Marimer LLC