Create and Bind Crystal Report in ASP.Net C# using Dataset

Here, we learn how to create crystal reports in asp.net, and how to bind data to crystal reports from sql server database.  here we are using dataset method for bind data to crystal reports in ASP.Net.

For binding data to crystal reports, first we must need to create a new database in sql server and create a table and a select stored procedure in database. after finishing this we have to make connection between asp.net web application and sql server using Dataset method.

Here, first we create new Database in sql server and create new Table within a Database.

- Create a new Table “StuMSt” in SQL – server with some columns.

 

Create a new Table in sql server for Bind Crystal Report.

Create a new Table in sql server for Bind Crystal Report.

- Create a SELECT Stored Procedure in sql server for select data.

Create a new Select Stored Procedure in sql server for Bind Crystal Report.

Create a new SELECT Stored Procedure in sql server for Bind Crystal Report.

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO

ALTER PROCEDURE [dbo].[STUDENT_SELECT]
AS
BEGIN

SELECT * FROM STUMST

END

 

Now, create a new asp.net web application for bind crystal report.

Create New ASP.Net web application with C#

Create New ASP.Net web application with C#

 

After, create a asp.net web application we have to make connection between asp.net web application and sql server database. we are using dataset method for asp.net connection.

Create New DataSet in asp.net web application in Solution Explorer.

Solution Explorer >> Right Click on Project >> Add New Item >> DataSet

Create New Dataset in ASP.net for sql server connectivity.

Create New Dataset in ASP.net for sql server connectivity.

 

Create New Dataset in ASP.net for sql server connectivity.

Create New Dataset in ASP.net for sql server connectivity.

 

Create New Dataset in ASP.net for sql server connectivity.

Create New Connection with SQL Express for connectivity.

 

Create New Dataset in ASP.net for sql server connectivity.

Bind sql stored procedure with dataset.

Create New Dataset in ASP.net for sql server connectivity.

Bind Select Stored procedure to dataset in asp.net

 

Create New Dataset in ASP.net for sql server connectivity.

Create New Dataset in ASP.net for sql server connectivity.

 

Create New Dataset in ASP.net for sql server connectivity.

Create New Dataset in ASP.net for sql server connectivity.

 

Now, finishing dataset binding we create a new crystal reports. for Display crystal reports on web form we have to take a CrystalReportViewer  from toolbox on web asp.net web form.

Add CrystalReportViewer on asp.net web forms for display Crystal Report.

Add CrystalReportViewer on asp.net web forms for display Crystal Report.

 

Now, Create a New Crystal Reports in asp.net web application.

Solution Explorer >> Right Click on Project >> Add New Item >> CrystalReport

Add New Crystal Report in asp.net web application.

Add New Crystal Report in asp.net web application.

 

Create and Bind Crystal Report in ASP.net using DataSet

Create and Bind Crystal Report in ASP.net using DataSet

- There are main five section in Crystal Reports.
1. Report Header : Report Header Generally used to Display Heading/Title of the Reports.
2. Page Header : Page Header used to Display Content/Data Heading or Title.
3. Detail : Detail used to Display the Data/Content of your Reports.
4. Report Footer : Report Footer used to Display Footer of the Reports.
5. Page Footer : Page Footer used to Display Page Number of the Reports.

Create and Bind Crystal Report in ASP.net using DataSet

Create and Bind Crystal Report in ASP.net using DataSet

 

Create and Bind Crystal Report in ASP.net using DataSet

Create and Bind Crystal Report in ASP.net using DataSet

 

Create and Bind Crystal Report in ASP.net using DataSet

Create and Bind Crystal Report in ASP.net using DataSet

 

Create and Bind Crystal Report in ASP.net using DataSet

Create and Bind Crystal Report in ASP.net using DataSet

 

Create and Bind Crystal Report in ASP.net using DataSet

Create and Bind Crystal Report in ASP.net using DataSet

 

Create and Bind Crystal Report in ASP.net using DataSet

Create and Bind Crystal Report in ASP.net using DataSet

 

Create and Bind Crystal Report in ASP.net using DataSet

Create and Bind Crystal Report in ASP.net using DataSet

- here is code for bind crystal report.

C# Code
- first add name space : using CrystalDecisions.CrystalReports.Engine;

 protected void Page_Load(object sender, EventArgs e)
{
DataSet1.STUDENT_SELECTDataTable StuDT = new DataSet1.STUDENT_SELECTDataTable();
DataSet1TableAdapters.STUDENT_SELECTTableAdapter StuAdapter = new DataSet1TableAdapters.STUDENT_SELECTTableAdapter();

StuDT = StuAdapter.Select();

ReportDocument rept = new ReportDocument();
string spath = “E:/BLOG/RExample/CrystalReport.rpt”;
rept.Load(spath);
rept.SetDataSource((DataTable)StuDT);
CrystalReportViewer1.ReportSource = rept;

}

VB.Net Code
Import namespace  : Imports CrystalDecisions.CrystalReports.Engine

Dim StuDT As DataSet1.STUDENT_SELECTDataTable = New DataSet1.STUDENT_SELECTDataTable()
Dim StuAdapter As DataSet1TableAdapters.STUDENT_SELECTTableAdapter = New DataSet1TableAdapters.STUDENT_SELECTTableAdapter()

StuDT = StuAdapter.Select()
Dim rept As ReportDocument = New ReportDocument()

rept.Load(Server.MapPath(“~/CrystalReport.rpt”))
rept.SetDataSource(CType(StuDT, DataTable))
CrystalReportViewer1.ReportSource = rept

 

Create and Bind Crystal Report in ASP.net using DataSet

Create and Bind Crystal Report in ASP.net using DataSet

Leave a Reply

Your email address will not be published. Required fields are marked *

1 + 9 =


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">