06 October 2009

Crystal Report on WebPages

  1. Add a Dataset item and create a table with the name “Resume” as below

    dataset
  2. Add this Dataset to crystal Report
  3. Write below following code
using System;
using System.Collections;
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 System.Data.SqlClient;

using CrystalDecisions;
using CrystalDecisions.CrystalReports;
using CrystalDecisions.CrystalReports.Engine;

public partial class Seeker_resume : System.Web.UI.Page
{
    datacon obj = new datacon();
    protected void Page_Load(object sender, EventArgs e)
    {
        obj.da = new SqlDataAdapter("select companyname as Column1,password as Column2 from provider", obj.cn);
        obj.da.Fill(obj.ds,"Resume");
        ReportDocument myreport = new ReportDocument();

        myreport.Load(@"E:\STUDENTS\Sunitha\Project\CrystalReport.rpt");
        //myreport.Database.Tables[""].SetDataSource(ds);
        myreport.SetDataSource(obj.ds);
        CrystalReportViewer1.ReportSource=myreport;
        CrystalReportViewer1.DataBind();
    }
}