Email: Password:       Forgot Password 
    .netCodeSG
A Saarsha Group Online Community for dot net codes group like C#, Asp.NET, VB.NET, Sharepoint, JavaScript, JQuery, Ajax, SQL, WCF, WPF.
 
TECHNOLOGIES:
 

Crystal Report in ASP.NET

Article:
Viewed:  1997 
Posted On:  14/09/2014 00:06:04 
What is Crystal Report? How we can Crystal Report in asp.net C# step by step? 

 

In this article I am going to explain Crystal Report in ASP.NET. Below is my Employee Table which data I will show as report in ASP.NET using Crystal Report.

1.png

Image 1.

Now Open Visual Studio -> File -> New Web Site

2.png

Image 2.

After this Right Click on Solution Explorer -> Add New Item -> Crystal Report -> Add.

3.png

Image 3.

4.png

Image 4.

Here Expand -> Create New Connection -> Select OLE DB(ADO) -> A pop up window will open ->Select Microsoft OLE DB Provider for SQL Server -> Next

5.png

Image 5.

Now Enter your SQL Server Details.

6.png

Image 6.

7.png

Image 7.

Now Select your Data Base -> Select Your Table and Move

8.png

Image 8.

Now Select those column which you want to show in reports. Click Finish.

9.png

Image 9.

Now you can see your report is ready. All Columns already in Details sections. You can remove any column or you can add new column by drag n drop from field explorer to report.

10.png

Image 10.

Now time to add a Report Viewer where we can show this Crystal Report. On Default.aspx page, drag n drop CrystalReportViewer from tool box like below.

11.png

Image 11.

Now on Page_Load event write below code:

using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using CrystalDecisions.CrystalReports.Engine;
 
public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        ReportDocument crystalRpt = new ReportDocument();
        crystalRpt.Load(Server.MapPath("EmployeeCrystalReport.rpt"));
        CrystalReportViewer1.ReportSource = crystalRpt ;        
    }
}
 

Now Run your Application:

12.png

Image 12.

  Comment:
         HOME   |   Submit Article   |   Contact Us   |   About Us   |   Terms & Condition   |   Advertise With us