Technology

ASP NET Hosting: Tips for Generating Crystal Reports in Visual Studio 2012

Crystal Reports is powerful interactive report design software designed for developers. It allows you to conceive, investigate, explore and disseminate reports from the web or integrate them into company applications. The report is made from a friendly and ergonomic graphical interface.

In addition, Crystal Reports is a popular Windows-based report writer (report generation program) that enables a programmer to create reports from a variety of data sources with minimal written code. Developed by Seagate Software, Crystal Reports can access data from widely used databases and can integrate data from multiple databases into 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 to VS 12, when I am very comfortable with VS 2010 or 2008? This is a question that arises from most technicians. Most of us get used to an environment, and when a new one arrives, we often think about switching to it. The five features that will force you to switch to VS 12:

  1. The new look and feel
  2. It is ready for Windows 8
  3. Updated web development environment
  4. It’s ready for the cloud and for serious business
  5. Has a flexible and robust ALM

Microsoft Visual Studio 2012 enables developers to quickly create connected applications that provide rich user experiences. Visual Studio offers developer advancements in three main areas:

  • Rapid application development
  • Break user experiences

In this article I want to generate Crystal Report in Visual Studio 2012 for ASP.NET. Follow the steps below:

  1. Took a DataSet, then added a DataTable. Three columns were added from my SQL database table: id, pname, price.
  2. Took a CrystalReport.rpt and the selected usage report wizard. Aggregate data set.

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();
}
}

Here are the steps to generate a Crystal report in Visual Studio 2012 for ASP.NET.

Leave a Reply

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