1

I'm new to reporting so need some good information/resources to help me get some reports set up in our 3-tier app.

We currently have: UI (ASP.Net MVC 2 at present but also winforms in future), Business Logic and DAL (Entity Framework - Code-Only ie no edmx)

The BL has "manager" objects for selecting and manipulating entities.

Now I've started by creating a .rdlc report and have chosen as a data source an object which wraps the BL managers to retrieve the appropriate records.

Now I'm trying to add a front-end to see if my report works... I believe there's no good way to do a ReportViewer in a pure MVC way so I'm planning to use a .aspx webform. I've added the ReportViewer control but am unsure how to wire it up to my report...

I had expected to instantiate the report I created (which lives in the BL) and pass it to the viewer - But this doesn't seem to be the way it's supposed to work?

I've googled and have only found references to the ReportViewer either accessing a URL or a local file for the rdlc.

(For the moment, assume I don't have access to SSRS)

I don't see how either a local file OR a url helps me. If I were to point directly at the rdlc using a local path, I have no idea how I can properly initialise the ObjectDataSource - it relies on dependency injection and has a lot of dependencies.

If I point at a URL, I presumably need a reporting server up - and if the report lives on there, there's no way it can reference my business logic/DAL - Which means I'm maintaining 2 methods of accessing data in parallel - which seems awful to me.

I'm obviously approaching this wrong but most of the tutorials I can find assume the reports all live in the UI layer and have data sources specified on the webform itself - which is not what I need in this case. In theory, I should be able to provide a winforms front-end to the BL and have it generate exactly the same report with minimal effort.

Can someone please point me in the right direction.

Many thanks

In case it's relevant, I'm using .Net 4, VS2010, MVC 2 and IIS 7.

Basic
  • 26,321
  • 24
  • 115
  • 201
  • What exactly are you trying to do? Does your report depend on something (class/object/resource) in your solution? – Alex Essilfie Sep 16 '10 at 13:15
  • Sorry for the delay - meeting. I'm having trouble getting ym head around how reports actually get displayed. I've plqayed with a Telerik demo which instantiates a report object, sets some properties and passes it to the reportviewer. I think what's happening here is that I design the report to handle data type X and then point a report viewer at the rdlc file and then have a data source on the webpage which generates data of type X and is referenced by the viewer? In short, I've got an rdlc - how do I display it? – Basic Sep 16 '10 at 14:25
  • I get your question now. You've designed a report (rdlc) and you'd like to display it in ReportViewer control right? – Alex Essilfie Sep 16 '10 at 15:01
  • Sorry about not getting to you earlier. I'm currently working on a project whose deadline is tomorrow. I'll try to get to you as soon as possible. The only caveat is, I work with Winforms only. No ASP whatsoever. But as long as it's .NET, any help I offer should be enough to point you in the right direction. – Alex Essilfie Sep 17 '10 at 14:35
  • No worries - I know how it is. I'm sure the winforms approach should be sufficient to point em in the right direction. Cheers – Basic Sep 17 '10 at 14:52
  • I'm looking at it right now. You should get a reply in about 30 min. – Alex Essilfie Sep 20 '10 at 13:55

1 Answers1

1

As I said earlier, I do not do ASP so I don't know how resources used in such projects are deployed.
In WinForms projects, there are generally two options for deploying reports:

  • Embedded Resource (included in the output executable)
  • Content (Copied to the output directory)

Here is code that illustrates both procedures. It is an extract from my answer to your previous question.

With rptVwr.LocalReport
    'use this if the report is embedded in the project                     '
    'the name is of the following format [ProjectNamespace].[ReportName]   '
    .ReportEmbeddedResource = "ObjectReport.SampleReport.rdlc"

    'use the ReportPath if the report is stored somewhere else             '
    .ReportPath = "C:\Path\to\your\report" 'For demonstration purposes only'
End With

As you can see, when the report is embedded, you just assign the report as I illustrated in the accompanying comment.

I think, based on the nature of your project, you should set the report's Build Action in the Properties window as an embedded resource. That way, it can be accessed from wherever it is deployed.


Edit 1
I was looking through the MSDN Library and I found this article which covers server reports. Just scroll to the code section. I think it has what you're looking for.

There was also an article on CodeProject which covers your request extensively.

After skimming through, it appears you have to do the following:

  1. Set the report viewer's ProcessingMode property to Server.
  2. Enter the path (url) of the report in the ServerReport.ReportServerUrl property.
  3. Enter the location of the report in the ServerReport.ReportPath property.

Properties Window for Server Reports


Conclusion:

When deploying desktop applications, use the LocalReport property of the ReportViewer control and set the ProcessingMode to Local.
When deploying web-based projects use the ServerReoprt property of the ReportViewer control and set the ProcessingMode to Remote.

Community
  • 1
  • 1
Alex Essilfie
  • 12,339
  • 9
  • 70
  • 108
  • Thanks for the detailed write-up. It's probably going to be tomorrow before I can try it out - I'll be back to you then. – Basic Sep 20 '10 at 17:11
  • Always a pleasure. Is there any other MS Report question bugging you? – Alex Essilfie Sep 21 '10 at 11:11
  • Not at present - "unfortunately", I've been pulled off reports for a week or two :D If I get any more, I'll comment here so you know :) – Basic Sep 21 '10 at 12:15