3
Answers

creating crystal report in C#.net asp.net V-Studio 2012

wish dar

wish dar

10y
1.1k
1
Hi,
 
I'm having problem in displaying my crystal report. Whenever I run my program, details are not showing. I already created the layout(.rpt) and my webform which only contains the CrystalReportViewer. Details are connected to my SQL Database 2008.
Here's my code behind. What am I missing?
 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Data;
namespace Demo
{
public partial class WebForm1 : System.Web.UI.Page
{
public string GetConnectionString()
{
return System.Configuration.ConfigurationManager.ConnectionStrings["connString"].ConnectionString;
}
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection(GetConnectionString());
SqlDataAdapter ad = new SqlDataAdapter("Select city_code, city_cd from cities", GetConnectionString());
DataTable _dt = new DataTable();
ad.Fill(_dt);
CrystalReport3 rpt = new CrystalReport3();
rpt.SetDataSource(_dt);
CrystalReportViewer1.ReportSource = rpt;
CrystalReportViewer1.DataBind();
}
}
 
Appreciate your help a lot. 

Answers (3)