Hello,in this c# tutorial i will explain how to display data from database to RDLC report using c# windows application
What is RDLC?
RDLC Stands for Report Definition Language Client Side.
It is used to create reports using Microsoft Reporting Technology.
RDLC is a built-in reporting service in Visual Studio Editor.
To display data in RDLC using MicrosoftReportViwer control and Typed Dataset
1 .Create a database name as StudentDetails using SQL SERVER.Create a Table name as StudentMarksheet in this database.
Column Name
|
Data Types
|
Id
|
Int [Identity Property Set =True]
|
StudentName
|
varchar(50)
|
StudentMarks
|
float
|
2. Open VisualStudio.Net / Select C# / Windows Application
3.Add ReportViewer control from ToolBox / Reporting to windows form for view reports

4.Add Dataset to project for that ,Right click on project /new item / data / select dataset
Click on add Datset1.xsd will be added to project

5. Add datatable to Datset1.xsd ,for that Right click on Datset1.xsd/add datatable

6.Add columns to datatable,for that Right click on datatable add columns StudentId,Name,StudentMailId

7.Add RDLC report to Form by adding report wizard,for that Right click on project/ new item/ reporting /select report wizard

in report wizard select datasorce as created Dataset1.xsd, fields automatically added on report wizard.

8. Click next
9.now to show fields in report drag columns to Values Box

10.click next ,chose layout click next

11.choose report style Ocean

12.Click on Finish
13.The Report is ready and is displayed in the Visual Studio as shown below.

14.Go to form click on report viwer smart tag to select created report i.e Report1.rdlc

15.Following code for display data in RDLC report from datatbase
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlClient;
using Microsoft.Reporting.WinForms;
namespace ReportsRDLC
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
DataSet1 ds = GetData();
ReportDataSource datasource = new ReportDataSource("DataSet1", ds.Tables[0]);
this.reportViewer1.LocalReport.DataSources.Clear();
this.reportViewer1.LocalReport.DataSources.Add(datasource);
this.reportViewer1.RefreshReport();
}
private DataSet1 GetData()
{
SqlConnection con = new SqlConnection(@"Data Source=.\sqlexpress;Initial Catalog=StudentDetails;Integrated Security=True");
SqlCommand cmd = new SqlCommand("SELECT * FROM StudentMarksheet", con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet1 ds = new DataSet1();
da.Fill(ds, "DataTable1");
return ds;
}
}
}