using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data; using System.Data.SqlClient; using CrystalDecisions.CrystalReports.Engine; using CrystalDecisions.Shared; using System.Configuration; public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { ReportDocument rd = new ReportDocument(); DataSet1 ds1 = new DataSet1(); DataTable dt = new DataTable(); dt.TableName = "Crystal Repoart"; dt = getallordeer(); ds1.Tables[0].Merge(dt); rd.Load("C:\\Documents and Settings\\sakshi.k\\My Documents\\Visual Studio 2010\\WebSites\\WebSite2\\CrystalReport.rpt"); rd.SetDataSource(ds1); CrystalReportViewer1.ReportSource = rd; } public DataTable getallordeer() { SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["learnConnectionString"].ConnectionString); SqlCommand cmd = new SqlCommand(); DataSet ds = null; SqlDataAdapter Sda; try { conn.Open(); cmd.CommandText = "select customer_name,order_id,product_name,product_qty from customer1"; cmd.CommandType = CommandType.Text; cmd.Connection = conn; ds = new DataSet(); Sda = new SqlDataAdapter(cmd); Sda.Fill(ds); } catch (Exception ex) { throw new Exception(ex.Message); } finally { cmd.Dispose(); conn.Close(); } return ds.Tables[0]; } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)