ASP NET Hosting – Tips to Generate Crystal Reports in Visual Studio 2012
Crystal Reports is a powerful software to design dynamic and interactive report designed for developers. It allows to conceive, investigate, explore and diffuse reports from the web or integrate into company applications. The report is made from a friendly and ergonomic graphic interface.
Furthermore, Crystal Reports is a popular Windows-based report writer (report generation program) that allows a programmer to create reports from a variety of data sources with a minimum of written code. Developed by Seagate Software, Crystal Reports can access data from most widely-used databases and can integrate data from multiple databases within one report using Open Database Connectivity (ODBC).
Microsoft Visual Studio 2012 is the latest Integration Development Environment (IDE) from Microsoft. But the question arises. Why should I switch over to VS 12, when I am very much comfortable with VS 2010 or 2008? This is a question that comes out from most techies. Most of us get used to an environment and when a new one comes we often think to switch over to it. The five features that will compel you to switch over to VS 12:
- The All new Look and Feel
- It is Ready for Windows 8
- Upgraded Web Development Environment
- It is Cloud Ready and Up for Serious Business
- It has a flexible and Solid ALM
Microsoft Visual Studio 2012 enables developers to quickly create connected applications that deliver rich user experiences. Visual Studio delivers advances for developers in three primary areas:
- Rapid Application Development
- Break Through User Experiences
In this article I want to generate Crystal Report in Visual studio 2012 for ASP.NET. Follow the below steps:
- Took a DataSet, then added a DataTable. Added three columns as of my sql database table: id, pname, price.
- Took a CrystalReport.rpt and Selected Use Report Wizard. Added dataset.
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using System.Data;
using System.Data.SqlClient;public partial class _Default: System.Web.UI.Page
{
private SqlConnection cn = new SqlConnection("user id=sa;password=chiklu;database=SRS;server=CHIKLU-PC");
protected void Page_Load(object sender, EventArgs e)
{
cn.Open();
SqlCommand cmd = new SqlCommand("SELECT abcd.id,abcd.pname,qwer.price FROM abcd JOIN qwer ON abcd.id=qwer.id",cn);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
ReportDocument rpd = new ReportDocument();
rpd.Load(Server.MapPath("CrystalReport.rpt"));
rpd.SetDatabaseLogon("sa","chiklu","CHIKLU-PC","SRS");
rpd.SetDataSource(ds);
CrystalReportViewer1.ReportSource = rpd;
cn.Close();
}
}
That’s steps to generate crystal report in Visual studio 2012 for ASP.NET.