Click here to Skip to main content
16,005,316 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,

How to Generate a report using Crystal Reports in Visual Studio 2010?
Posted

it may be useful for you.......

Let's try it

Generate a report using Crystal Reports in Visual Studio 2010
 
Share this answer
 
First u create One Aspx.File and Take CrystalReport Viewer Control which is placed in ToolBox.

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<link href="/aspnet_client/System_Web/2_0_50727/CrystalReportWebFormViewer3/css/default.css"
rel="stylesheet" type="text/css" />
<link href="/aspnet_client/System_Web/2_0_50727/CrystalReportWebFormViewer3/css/default.css"
rel="stylesheet" type="text/css" />
<link href="/aspnet_client/System_Web/2_0_50727/CrystalReportWebFormViewer3/css/default.css"
rel="stylesheet" type="text/css" />
</head>
<body>
<form id="form1" runat="server">
<div>
<CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" AutoDataBind="true"
Style="position: relative" />
&nbsp;

</div>
</form>
</body>
</html>

in Aspx.CS FILE

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using CrystalDecisions.CrystalReports;
using CrystalDecisions.CrystalReports.Engine;
using System.Data.SqlClient;

protected void Page_Load(object sender, EventArgs e)
{

ReportDocument doc = new ReportDocument();



JPCIReports.classwiseDataTable cldt = new JPCIReports.classwiseDataTable();
SqlDataAdapter ad = new SqlDataAdapter(SELECT * from Tablename",con");
ad.Fill(cldt);
doc.SetDataSource((DataTable)cldt);
CrystalReportViewer1.ReportSource = doc;
CrystalReportViewer1.DataBind();
}
}
 
Share this answer
 
Comments
Ravidake 1-Sep-11 9:01am    
Hi Archana,

what is JPCIReports.classwiseDataTable.

where we create this? is this a datatable or dataset?

thanks
ravi k dake

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900