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.
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.
Step 3: Now click on Toolbox and expand Data, now add BindingSource to your project solution.
Step 4: Now mouse right click, Click on Add, next sub menu TableAdapter option.
Step 5: Now TableAdapter Configuration Wizard will open, here you'll able see different DataTable properties and then hit on Finish button.
Step 6: Here you'll be able to select Choose a Command type, three main Command Types are as follows:
- Use SQL Statements
- Make a new Stored Procedure
- Use Existing Stored Procedure
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:
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.
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.
Step 7: Now move to RDLC report, mouse right click, click on Insert option then click on sub option Table.
Step 7: Now move to RDLC report, mouse right click, click on Insert option then click on sub option 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.
Step 8: Now select Data Sources, here you'll be able see table entities, now drop these entities to RDLC report to populate.
Step 9: Now right click on Table, here you can add Page Header, Page 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).
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.
Step 12: Now right click on ReportViewer, you've to provide Data source and Choose Report Name.
Step 13: Now you have to compile your application and run finally to see RDLC Reports final results.
Step 8: Now select Data Sources, here you'll be able see table entities, now drop these entities to RDLC report to populate.
Step 9: Now right click on Table, here you can add Page Header, Page 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).
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.
Step 12: Now right click on ReportViewer, you've to provide Data source and Choose Report Name.
Step 13: Now you have to compile your application and run finally to see RDLC Reports final results.
RDLC Report Main Components
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
Development Environment: Visual Studio 2013, .NET Framework Version 4.5, MS SQL Server 2012
how to use where clause ?
ReplyDeletei want to use search condition on print.cs.In that i am using text box and button of search.
ReplyDeleteyou can filter on reportviewer, here is a article https://msdn.microsoft.com/en-IN/library/ms252125(v=vs.80).aspx
ReplyDeletedownload this project then you will see code to filter in cs file, here is a sample dt = clsCommon.PopulateDt(dt, "Select * from vw_Staff");
ReplyDeletethis.bindingSource1.DataSource = dt;
ReportDataSource _rep = new ReportDataSource("db_Staff", this.bindingSource1);
reportViewer1.LocalReport.DataSources.Clear();
reportViewer1.LocalReport.DataSources.Add(_rep);
reportViewer1.RefreshReport();
please tell me how to create subreport of rdlc
DeleteI am sharing few samples how to generate sub report in rdlc 1) https://msdn.microsoft.com/en-in/library/ms251765(v=vs.90).aspx
Delete2) 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.