Now a days for reporting purposes we have a lots of choice. RDLC report is one of the most popular reporting engine for Asp.net developers. Using RDLC report you can easily represent data to the end user. You can also export the report in Excel, PDF & MS Word format. Print functionality also in built in this ReportViewer control. This a very basic RDLC report tutorial for beginners. In my next articles I will also provide more example on RDLC report. Here I am providing “Creating RDLC report Step by Step in Asp.Net C# & VB.Net“. Hope it will help you.
In this example I am using below SQL Server Table:
Steps to Create RDLC Report:
1. Add your connection string in Web.Config file like below:
<configuration> <connectionStrings> <add name="DBConnection" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=TESTDB;Trusted_Connection=yes;" providerName="System.Data.SqlClient"/> <!--<add name="BONConnection" connectionString="Data Source=XXX.com;Initial Catalog=DBNAME;User Id=UserName;Password=YourPassword;" providerName="System.Data.SqlClient" />--> </connectionStrings> ................... ...................
Note: If you use windows authentication then use the first key. Otherwise use second key line. Update server name, Database name, User name, Password as per your settings. I will describe the necessity later.
2. Add a ReportViewer from Reporting Tab under Toolbox:
3. Now go to the Design View of your page. Select the ReportViewer control. Click on smart menu and click on “Design a new report”:
4. Now choose your Data Connection:
Note: The wizard automatically fetch the connection string from your Web.Config file.
5. Now click on Next and select the “Student” table:
6. Click Finish, Click Next. An “Arrange Fields” page will popup. Move all columns from “Available Fields” to “Values” Field. Click on “Roll” column and uncheck the column:
7. Now the “Values” Field will look like below:
8. Now click Next, click Next. Now choose your report style from left pane:
9. Now click “Finish”.
10. Now open your page in design view. Click on ReportViewer control. Click on smart menu. Select “Report1.rdlc” from “Choose Report” DropDown List:
11. Now run the project. Oops you will get the error “The Report Viewer Web Control requires a System.Web.UI.ScriptManager on the web form”:
12. To resolve the error add a “ScriptManager” in your page:
13. Now run the project. Hope you will get a report like below:
Start RDLC report. It’s simply amazing.