Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Microsoft SQL Server Reporting Services (SSRS) using LINQ and ASP.NET

0.00/5 (No votes)
13 May 2010 1  
My first example of using Microsoft SQL Server 2008 Reporting Services (SSRS)

Introduction

What I want to do here is help out those who are just starting out with .NET 3.5 and the SSRS, if you follow the steps listed below you will be able to create your first Report.

Background

I have used VS 2008 and SQL 2005 and Linq for this example.

Steps

  1. Create a table for example StudentInfo:

  2. Add some data to your table:

    Report2.jpg

  3. Create a new project using VS 2008:

    Report3.jpg

  4. Add new item to your project:

    Report4.jpg

  5. Select the report from the list of item:

    Report5.jpg

  6. Enter your report name:

    Now what you have to do is drag the ReportViewer to your aspx page:

    Report6.jpg

    Select the datasource of your Reportviewer:

    Report7.jpg

This how your HTML page will look:

Report8.jpg

Here are some of the steps you have to do:

Add a dataset to your project and add a datatable to the dataset. I use MyDataset and DataTable StudentInfoDataTable. Here is the code you have to copy to your page load event:

protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
MyDataClassesDataContext db = new MyDataClassesDataContext();
IQueryable<StudentInfo> data = from d in db.StudentInfos select d;
ReportDataSource rds = new ReportDataSource("MyDataSet_StudentInfoDataTable", data);
ReportViewer1.LocalReport.DataSources.Add(rds);
}
}

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here