Microsoft has released typed data set to work with .NET applications. This article will explore about creating report in ASP.NET with typed dataset. When we implement crystal report with typed dataset, it’s easy to work data table.


The purpose of this tutorial is to illustrate how to create report in ASP.NET Applications with type DataSet. As we mentioned in our earlier articles, reporting is the most important feature in many Information systems. Therefore, Crystal Report has supported web Application reporting. ASP.NET has a feature to develop reporting with crystal reports too.


    1. SQL Server 2005
    2. Visual Studio 2005/2008
    3. Crystal Report

Before you start to design a report, you need a database which is going to use by the report. Here we have designed a small database for this demonstration.

The created database name is “HouseRental” with “HouseOwnerInfo” table. There are eight columns in the “HouseOwnerInfo.
Let us design a report to this table, to get owners summary report.

Note: The database design is only for demonstration purpose.

Let us start designing the report. For that, there are two standard ways. The first way is we can use the Crystal Report and second one is we can use the Visual Studio. Here we have used Visual Studio, since we prefer that. (We have used this same method in our earlier articles as well).
First, open Visual Studio 2008 or 2005 and create new web project called “CrystalReportInPart02ASPNET”. Then right click the project and select Add New Item from the bar. Select Crystal Report from the templates list window. When you select crystal report, give a meaningful name to the report. Here we have given “SamplewithDSRpt.rpt”. Then click Add button.

After you click the Add button, you will get a welcome window as shown by the following figure.

Keep the standard report format and click OK button. Then you need to create the database connection to access tables within the database. Once you click OK button, system gives a window to select the connection type (database provider) as shown below.

This demonstration report is to work with SQL Server 2005 database. So, you need to select SQL native client as provider (As above figure shows).

Then click Next button, to continue report creation process. Then you need to assign details of SQL Server and user credential to access the database from the report. Then you need to expand current connection tag, select your database connection then select the relevant table as shown by the following figure.

 Then click Next button to continue. There you need to select fields from selected tables to design report as shown by the following figure.

Then click Next button. Now you have done necessary effort and finished the final step. As a result, you will get report like this.

Then we need to go for the next section, in which you need to create typed DataSet from demonstration table. This demonstration will explore how we create report with typed DataSet.

Now right click on your project. Now select the new item menu, then select DataSet in the item list like following.

And don’t forget to supply a name, here we have given name as “HouseRentalDS.xsd” and then click to add button to add to project.

When Dataset added to the project, it will show just an empty space. Then we need to connect database through the Server Explore, then create a connection to your database. Now drag and drop the table on the Dataset surface as like follow,

    Figure: Visual Studio Server explore and typed Data Set Designed View

Now we have created typed DataSet and report design, now we need to write code to integrate both.

Before that we need to add report viewer to the web page. Let us see how we can add the report viewer in the page, look at these HTML tags.

Now create a table with form object and then add a HTML row and a column also.

Then place the crystalReportViewer to the column as shown by above HTML tag.

If we compile this application, it will give a compiler error “CR doesn’t exist”. Therefore, you need  to register crystal report namespace on the top of the page as shown below.

Note: When you double click on toolbox in the crystalreportviewer, Visual Studio will do all registration and etc.

Now you need to write few lines to integrate report and DataSet. Here we  need to write codes for two portions. The first one is to access database and fill records to DataSet and the second one is pass the dataset to the report and load the report within crystal reportviewer.

Both sections are pretty simple. First we write code for access the database. For that  we have created a class call “DataBaseAccess.cs”  within that we have a method like follow,

In the above lines of code, initialize SqlConnection object and then assign connection string to that object.

then we need SqlCommand to acces theT-SQL script with database


When we use the “using “ scope, get instance from the IDispose implemented classes, it properly dispose the all resource from the memory. For more information about using IDispose object.



Then  fill records to dataset  table and finally return dataset.

Now we have records  in the dataset , we need to set records  to report using  SetDataSource method. Look the below code for this operation,

DataBaseAccess is custom class to retrieve records from the database. First we need to get instance to dataaccess classs  and also create new object  ReportDocument too.

Then load designed report file  from the physical location using Load method and find the full path using  Server.mapPath(filename”);

Then call method to access the database and retrieve the records by

Then we need to set Data source to the report and then finally set report object to the report Viewer.

From the above approach we have an advantage,what is that? In the previous articles we set database logon information to report file, but here we don’t need that because, when we try to retrieve records from the database with dataset, we have set the connection information. So now it is working like Disconnected mode ADO.NET Access.

Since report using records which are within the dataset so, we do not need set connection information report.

Now build the application and run, you would get result like follows,

That’s all .We hope you can do it.


In this article you have learned about creating report in ASP.NET using Typed DataSet.  Here you got a good idea and solution how to set database logon settings to report issues.




Author's information:

Name : RRaveen

Degree: B.Sc. degree in Computer Science.
- 4+ years experience in, and JAVA.
- Obsessed in OOP style design and programming.
- Designing and developing Network security tools.
- Designing and developing a client/server application for sharing files among users in a
  way other than FTP protocol.
- Designing and implementing GSM gateway applications and bulk messaging.
- Windows Mobile and Symbian Programming
- Having knowledge with ERP solutions

The summary of my skills:
C#, VB.Net#,, VC++, Java, WPF,WCF, SilverLight,Oracle,PL/SQL, SQL Server, MS Access

My Web Blogs