In this post I have explained crystal report simple example
in asp.net.
Description:-
Crystal report is application program used to design and generate
reports from wide range of data source.
If you are new in crystal report and using
visual studio 2010 , you will face with some problem regarding crystal
report because crystal report has not in build in VS 2010. So see my previous
post How to install crystal report in VS 2010.Lets
start with practical approach.
First Create a database table like this:-
Create table EmpDeatils(EmpID int
primary key, EmpName varchar(50),Country varchar(50));
Put some dummy data in the table.
Now Open Visual Studio 2010 -> Open New Website ->
Click on Empty Web application -> give a project name -> click ok.
Now right click on project -> add new items -> click
on web page -> give name -> click ok.
Again right click on project -> add new items -> click
on crystal report -> click ok.
After that crystal report will prompt crystal report gallery
window in that select blank option and click ok.
After that click on crystal report menu bar under the
database -> database expert.
After click on Database expert , Database expert window will open in that
select Create new section.
After that select Microsoft OLE DB Provider for SQL and
click next.
After that enter your server name and database name and
click next
After that again new prompt window will come and click on
finish button.
After clicking the finish button now database will loaded in
OLEDB section. Select your database
-> select dbo -> select your table (which you want).
Now open the table and move the selected table and click ok.
After that database fields in Field Explorer populated with your
required data table .
Now drag and drop the required fields from the data table to
the report details section.
Now open your design page and drag and drop CrystatReportViewer
control from Reporting tab.
Now select crystalReportViewer and click on smart tag in the
right hand side and choose new report source.
When you click on New Report Source , a new window will open
. Click on dropdown list and select crystalReport.rpt file.
After that your design page will look like this.
<%@ Register Assembly="CrystalDecisions.Web,
Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"
Namespace="CrystalDecisions.Web" TagPrefix="CR"
%>
<!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div align="center">
<CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server"
AutoDataBind="True"
Width="1104px"
GroupTreeImagesFolderUrl=""
Height="1202px"
ReportSourceID="CrystalReportSource1" ToolbarImagesFolderUrl=""
ToolPanelWidth="200px"/>
<CR:CrystalReportSource ID="CrystalReportSource1" runat="server">
<Report FileName="CrystalReport.rpt">
</Report>
</CR:CrystalReportSource>
</div>
</form>
</body>
</html>
Run you application . Your report will like this.
No comments:
Post a Comment
Note: only a member of this blog may post a comment.