Member Since 5/1/2012
3536889482_macro_thumb_bunttt
biju joseph
Published: 2/27/2013
Views: 86742| Comments

RDLC (Report Definition Language Client-side)

What is RDLC Reporting service?

RDLC stands for Report Definition Language Client-side. RDLC can be run completely client-side in the ReportViewer control. This removes the need for a Reporting Services instance, and even removes the need for any database connection whatsoever; but it adds the requirement that the data that is needed in the report has to be provided manually. RDLC reports do not store information about how to get data. RDLC reports can be executed directly by the ReportViewer control.

RDL VS RDLC

DL files are created by the SQL Server 2005 version of Report Designer. RDLC files are created by the Visual Studio 2008 version of Report Designer.RDL and RDLC formats have the same XML schema. However, in RDLC files, some values (such as query text) are allowed to be empty, which means that they are not immediately ready to be published to a Report Server. The missing values can be entered by opening the RDLC file using the SQL Server 2005 version of Report Designer. (You have to rename .rdlc to .rdl first.). RDL files are fully compatible with the ReportViewer control runtime. However, RDL files do not contain some information that the design-time of the ReportViewer control depends on for automatically generating data-binding code. By manually binding data, RDL files can be used in the ReportViewer control. New! See also the RDL Viewer sample program.
 
The ReportViewer control does not contain any logic for connecting to databases or executing queries. By separating out such logic, the ReportViewer has been made compatible with all data sources, including non-database data sources. However this means that when an RDL file is used by the ReportViewer control, the SQL related information in the RDL file is simply ignored by the control. It is the host application''s responsibility to connect to databases, execute queries and supply data to the ReportViewer control in the form of ADO.NET Data Tables.
 
RDL Much better development experience, more flexibility if you need to use some advanced features like scheduling, ad-hoc reporting, etc... RDLC (Local reports): Better control over the data before sending it to the report (easier to validate or manipulate the data prior to sending it to the report). It has much easier deployment and no need for an instance of Reporting Services.
 
One HUGE drawback with local reports is a known memory leak that can severely affect performance if your clients will be running numerous large reports. This is supposed to be addressed with the new VS2010 version of the report viewer.

How to create a RDLC report in VS 2008?

Step 1: Creating Client Report Definition (.rdlc) Files.
 
There are many ways for creating rdlc files. Follow any of these methods for creating rdlc file Create a new client report definition (.rdlc) file in Visual Studio. Convert an existing RDL file to rdlc or create rdlc file programmatically. I am dealing here only on creating new rdlc from VS.
 
         Select “Add new item” and select report/report wizard 


Selecting report will add an empty RDLC file whereas wizard will lead you to create a report with data connection.

  

If you are using report wizard, follow the following steps..

 

          

          Creating connection string 



 
Save connection string to web.config file


Choose your stored procedure/table/query
 
 
Add fields to report 

Complete the wizard 

          

Step 2: Creating a Data Set.

Select “add new item” to add a dataset to the project
           Add the new data set to the app_code folder


 
 
Step 3: Drag Table Adapter & Use the configuration wizard to configure the data set.


            

Select connection string 

Select one from options given




           

          

Solution explorer updated with dataset 

Instead of dataset you can also use object DataSource as data source of rdlc file.

Step 4: Adding DataSource to Report

Open rdlc file in the design view, Click on “Show data sources “under the “Data” menu item and you can simply drag and drop to               the report fields

          

          

Drag and drop a table from tool box.
          

Click on Reports→Data sources to add data sources to the report

           


           

Drag and drop the fields you wanted on the detail section of the table.


           
           

Add footer if needed 

.

          Place whatever controls you want on the report and drag field to its expression  

  

          

You have a couple of categories from which you can have data for the expression. Under global we have

Under parameter we have all the parameters you have added to the report.     

          

Step5: Adding Parameters to Report

To communicate between the UI and the report, use parameters.

To add parameter use Reports-> report parameters… menu item

         

RDLC file and the Dataset are ready and we can show the report in the web page. You can set the page properties using Report properties dialog

        

Step 6: Adding rdlc on aspx page

Add a new aspx page and drag a report view control on it. Use the smart tag to choose report. Once you add the report,

Report source as well can be configured.

Step7: Run the web page and you will be able to view the report.

           

Step 8: How to attach DataSource dynamically from C# to rdlc file

Step 9: How initialize parameters from C# to rdlc file

      // parameters are initialized for the report

      ReportParameter Param0 = new ReportParameter("fromDate", fromDate.ToString(dateFormat));

      ReportParameter Param1 = new ReportParameter("toDate", toDate.ToString(dateFormat));

      ReportViewer1.LocalReport.SetParameters(new ReportParameter[] { Param0, Param1 });

Step 10: How to set the report style landscape?
 
      Change this to 29.7cm & 21cm for A4 Landscape.
 
 

 

 
 
 
 
 
 
 
 
 
 
 
 

 
 
Step 11: Deployment Note.

       Add the following key to handler section of the web.config file

       <handlers>

       <add name="Reserved-ReportViewerWebControl-axd" path="Reserved.ReportViewerWebControl.axd"

         verb="*" type="Microsoft.Reporting.WebForms.HttpHandler,Culture=neutral" resourceType="Unspecified"/>

      </handlers>

 You may get this error “Server Error in ''/'' Application.

Could not load file or assembly ''Microsoft.ReportViewer.WebForms, Version=8.0.0.0'' or one of its dependencies. The system cannot find the file specified.”. To solve this manually, copy the following files to the bin folder of your website. 

Please make sure you have .NET Framework 3.5 installed on the computer.

When you run ReportViewer.exe, the following files are installed in the Global Assembly Cache folder on the deployment computer. 

Microsoft.ReportViewer.Common.dll

Microsoft.ReportViewer.ProcessingObjectModel.dll

Microsoft.ReportViewer.WebForms.dll

Microsoft.ReportViewer.WinForms.dll

Microsoft.ReportViewer.DataVisualization.dll

The error indicates that the system cannot load Microsoft.ReportViewer.Webforms. Please try to manually copy the Microsoft.ReportViewer.WebForms.dll file to the application folder /bin directory. Please refer to the following link for more information about the Report Viewer.

http://msdn.microsoft.com/en-us/library/ms251723.aspx

If you are publishing the webstie using framework 3.5 use “Allow this precompiled site to be updatable.

          

 
Date Validation in RDLC Reports  
  1. IIf(FormatDateTime(Fields!ReturnDate.Value,2)=CDate("1/1/0001"),
  2. DateDiff("d", Fields!DueDate.Value, Today()) * Fields!LateFee.Value,
  3. DateDiff("d", Fields!ReturnDate.Value, Fields!DueDate.Value))  
 
I found the following sites to be very useful while working with RDLC reporting

http://www.ssw.com.au/ssw/standards/rules/rulestobetterSQlreportingservices.aspx

 
 
 
Hope this helps
Tags: ASP.NET, RDLC

Related Blogs

Loading...