Labels

slider

Recent

Navigation

RDLC reports in C#

Reports in C#, RDLC reports in C#, RDLC reports in ASP.Net, RDLC reports in win forms, RDLC reports in Windows forms

Introduction

Here is disclosed in point of interest to create RDLC reports in C#, RDLC is great business insight (BI) instrument. RDLC is the best part to show reports in tabular form.

Step 1: Add new project, select Windows Desktop, then select Windows Forms Application and afterwards solution name and then lastly hit on OK button.

Create Solution for RDLC Report



Step 2: Now right click on your solution and click option add new item then window will appear, now at right hand side select Reporting and then click on Reporting, type RDLC report name Report1.RDLC and lastly hit Add button.

RDLC Report


Step 3: Now click on Toolbox and expand Data, now add BindingSource to your project solution.

Binding Source

Step 4: Now mouse right click, Click on Add, next sub menu TableAdapter option.

tableAdapter1

Step 5: Now TableAdapter Configuration Wizard will open, here you'll able see different DataTable properties and then hit on Finish button.

TableAdapter Configuration Wizard

Step 6: Here you'll be  able to select Choose a Command type, three main Command Types are as follows:
  1. Use SQL Statements
  2. Make a new Stored Procedure
  3. Use Existing Stored Procedure
I am running with SQL statements, Click on Next button.

Choose a Command Type

Save the Connection String to the Application Config File

Keep checked the checbox to store the connection string into application config file.
Choose Methods to Generate
There are three returning methods:
  • Fill a DataTable
  • Return a DataTable
  • Create Methods to send updates directly to the database (GenerateDBDirectMethods)
  • Finally click on Next button.
TableAdapter Configuration Wizard

Choose Your Data Connection

Here you can create your database connection on New Connection button, there're options to save connection string into config file or not, here I'm clicking on Yes to save connection string into application config file, then click on Next button.

Choose Data Connection


Step 7: Now move to RDLC report, mouse right click, click on Insert option then click on sub option Table.
Insert Table

Dataset Properties

Here you'll able to type your dataset name “DataSet1” and can provide Data Source then you'll be able to choose Available Datasets from drop down, click on OK button.

Dataset Properties

Step 8: Now select Data Sources, here you'll be able see table entities, now drop these entities to RDLC report to populate.

Datasources

Step 9: Now right click on Table, here you can add Page Header, Page Footer

RDLC header footer

Step 10: Here now you'll see report is populated City Primary Key, City Name, In page header you'll be able to add RDLC Report (City Details).

RDLC Report Design Preview

Step 11: Once more click on Toolbox, Go to Reporting option, from here drag ReportViewer onto C# forms where ever  you've to populate reports.

Report Viewer

Step 12: Now right click on ReportViewer, you've to provide Data source and Choose Report Name.

Report Viewer

Step 13: Now you have to compile your application and run finally to see RDLC Reports final results.

City Details

RDLC Report Main Components

Here you can see main binding source of the project which are displaying in your project task bar.

dataReport

Summary

Here you'll be able to see in detail how can we generate RDLC reports in C#.

Download Example in Zip

Database Script is under folder db_Script
Development Environment: Visual Studio 2013, .NET Framework Version 4.5, MS SQL Server 2012 

Relevant Reading

Share

Anjan kant

Outstanding journey in Microsoft Technologies (ASP.Net, C#, SQL Programming, WPF, Silverlight, WCF etc.), client side technologies AngularJS, KnockoutJS, Javascript, Ajax Calls, Json and Hybrid apps etc. I love to devote free time in writing, blogging, social networking and adventurous life

Post A Comment:

6 comments:

  1. i want to use search condition on print.cs.In that i am using text box and button of search.

    ReplyDelete
  2. you can filter on reportviewer, here is a article https://msdn.microsoft.com/en-IN/library/ms252125(v=vs.80).aspx

    ReplyDelete
  3. download this project then you will see code to filter in cs file, here is a sample dt = clsCommon.PopulateDt(dt, "Select * from vw_Staff");
    this.bindingSource1.DataSource = dt;
    ReportDataSource _rep = new ReportDataSource("db_Staff", this.bindingSource1);
    reportViewer1.LocalReport.DataSources.Clear();
    reportViewer1.LocalReport.DataSources.Add(_rep);
    reportViewer1.RefreshReport();

    ReplyDelete
    Replies
    1. please tell me how to create subreport of rdlc

      Delete
    2. I am sharing few samples how to generate sub report in rdlc 1) https://msdn.microsoft.com/en-in/library/ms251765(v=vs.90).aspx
      2) http://rohit-developer.blogspot.in/2015/02/sub-report-in-rdlc-report-viewer.html
      3) https://blogs.msdn.microsoft.com/selvar/2013/03/24/working-with-rdlc2012-and-passing-parameter-to-sub-report-in-report-viewer-2012-control/
      Hope, it will resolve your issue.

      Delete