In this article, I will guide you how to create RDLC Wizard report using ReportViewer in asp.net csharp step by step with the help of screen shoot.
- Create Project
- Create Database
- create Table
- Insert data into table
- Create RDLC report
- Drag and Drop ReportViewer
- Report Viewer Task
Open You Visual Studio 2008 and Create new Project from File |New | Project. Provide Name to the project Default will be webApplication. In the New Project window at top right corner you will see drop down in which showing Framework's to select as shown in Below Figure.Visual Studio 2008 is multi-version targeting.
Create Database tesing
Open MS sql 2008 File | New | Database engine query.Create Database with name testing as shown below query and press F5 to Excute
Create database tesing
Create Table Countries
To create table enter keyword Create Table followed by table name followed by the first column name, data type for that column, any optional constraints.Make sure you seperate each column definition with a comma.. Create Table Countries with field id(bigint),name(nvarchar(100)),code(nvarchar(50)) .Data type define what data should be used for that column. In my countries example i have define two constraint for name and code. and id is primary cannot be duplicate.Primay is used to prevent duplicate values.
Visual Studio 2008 web Application
From Toolbox (shortcut key Clrt + Alt + X) Expand reporting tag, Drag MicrosoftReportViewer to Default.aspx Page as shown in Below Figure.
Source View of Default.aspx Page
Open Source View (Shortcut key SHIFT + F7 ) of Default.aspx Page. Set width to 100% of ReportViewer to adjust on Browser as shown below Figure.
Desgin View of Default.aspx Page
As you see setting width 100% it auto adjust on screen as showning in Figure.
Right Click on your Project of Solution Explorer. Goto Add sub menu will open Click on New Item.
Add New Item
Add New Item Window will open. Now Select Report Wizard , default name will be Report1.rdlc you can chnage it but i am taking default name here.
Report wizard window will be open Click Next button to proceded.
Data Source Configuration Wizard
Data Source Configuration wizard window will open Click on New connection to create a new connection.
Create connecton to poll data from table countries.
Add connection window will display, to create connectoin successfully.
Apply following steps:
- Enter Server Name.
- Enter Credientail.
- Select database
To check connection is established successfully click on Test connection button. Connection will created Successfully.
After Clicking on Next button Data source will retrie data from database. Expand Tables tree. Select Countries Table from the tables tree.and click next button to proceded.
Select countries dataset from SocialNetwork1dataset as shown in figure.After click Next button SocialNetwork1DataSet.xsd file will be created on your project.
Now Select the Report type By default Tabular Radio button is selected.
RDLC Report Design
Click Finised you will see Report1.rdlc is created in your project as shown in below figure.
Open Default.aspx Page select MicrosoftReportViewer, Click on Right Arrow at top right of MicrosoftreportViewer control.ReortViewerViewer Tasks small popup window will open. Choose report from dropdown list as shown in Below figure.
Display records in Broswer
Press Clrt + F5 to display Default.aspx page in you Browser.and you will see records are displayed.
This example tells you how simple is creating RDLC report in Visual studio 2008, using Report wizard you can create connection string,Databset,Rdlc report steps. with out writing an code.
This example will helps those users who are using Visual Studio but they dont have any Idea of creating RDLC report, this will helps you
Project Souce Code: visual Studio 2008 RDLC Wizard report by Aamir Hasan.rar (338.58 kb)
SQL MS 2008 Script: countries.sql (2.02 kb)