How to implement a "Layered Architecture" with SSRS and .net using reportviewer? RRS feed

  • Question

  • Hi,

    I have also posted this question in the SQL Server Forum, but it is basically an architecture question so I am hoping someone here can provide some knowledge...

    I have read a lot of articles about layered architecture with applications - how to separate into Data access layer, Business logic layer and presentation layer.

    My question is, when I use a reportviewer to display an SSRS report in my page, how do I apply the layered architecture as above? What is the presentation layer, what can be the business logic layer, and what can be the data access layer? Is it possible to have such a separation when the application makes use of a reportviewer control?

    Thanks in advance for your help.

    Thursday, March 8, 2012 7:13 PM

All replies

  • Yes, I would like to see how the SSRS fits into this.

    I have a gridview full of data and would like to export it or call the Stored Procedure that populated it via the BLL to get the data in SSRS.


    John F Lundy

    Tuesday, March 27, 2012 10:46 AM
  • I have used the reportviewer in a large n-tier project before.

    I needed to implement reporting using the  reportviewer control but for a large ehop where the data came from WCF services. The application itself was MVC so we could not use the reportviewer server control in the views pages.

    I basically used the reportviewer componennt  in a controller action where I would get the data from the wcf service and then render/stream out the reportviewer through an action result.  I used to design the report in VS against a mock List of DTO's I would be expecting from the WCF service. Ill have to go dig out the code and get back to you but look here... to get started

     The general MVC approach (taken from a snipper) is something like...

     public class ReportsController : Controller
            public ActionResult Reports()
                var ReportPath = Server.MapPath("~/Report1.rdlc");
                object Model = new GetDataFromWCF();
                RenderReport(ReportPath, Model);
                return View();
            private void RenderReport(string ReportPath, object Model)
                var localReport = new LocalReport { ReportPath = ReportPath };
                //Give the collection a name (EmployeeCollection) so that we can reference it in our report designer
                var reportDataSource = new ReportDataSource("EMPLOYEECOLLECTION", Model);
                //var reportType = "PDF";
                var reportType = "EXCEL";
                string mimeType;
                string encoding;
                string fileNameExtension;
                var deviceInfo =
                    string.Format("<DeviceInfo><OutputFormat>{0}</OutputFormat><PageWidth>8.5in</PageWidth><PageHeight>11in</PageHeight><MarginTop>0.5in</MarginTop><MarginLeft>1in</MarginLeft><MarginRight>1in</MarginRight><MarginBottom>0.5in</MarginBottom></DeviceInfo>", reportType);
                Warning[] warnings;
                string[] streams;
                //Render the report
                var renderedBytes = localReport.Render(
                    out mimeType,
                    out encoding,
                    out fileNameExtension,
                    out streams,
                    out warnings);
                //Clear the response stream and write the bytes to the outputstream
                //Set content-disposition to "attachment" so that user is prompted to take an action
                //on the file (open or save)
                Response.ContentType = mimeType;
                Response.AddHeader("content-disposition", "attachment; filename=foo." + fileNameExtension);

    Im my own implementation I had no access to the file system, so when I finished an rdlc report I would encoded as a string and store in the database. I would then retrieve and decode the string via WCF and then provide this markup to the reportviewer component to render and stream. Ill have a look for the code...

    Wednesday, April 4, 2012 8:55 AM
  • Report Viewer (Presentation Layer) à Business Logic Layerà Data Access Layerà Database

    Data Access Layer            à Connect to Your database, Select Data and return an Dataset.

    Business Logic Layer       à Call Data Access Layer and apply some business logic required to show to your report and return as Dataset.

    Presentation Layer          à Call business logic layer and set data source as dataset which is returned by business Logic Layer.

    Lingaraj Mishra

    Friday, April 6, 2012 11:54 AM