Click here to Skip to main content
Click here to Skip to main content

Crystal Reports PUSH method using ASP.NET

, 21 Mar 2003
Rate this:
Please Sign up or sign in to vote.
This article explains how to use PUSH method for drawing reports.

Introduction

This article explains how to use PUSH method for drawing reports. It will also explain how to use user DataSets in an ASP.NET page for reports. There are two types of methods for drawing the reports:

  1. PULL method- the crystal report makes connection with the database, brings the fields data and draws the report.
  2. PUSH method- we create the DataSet, choose fields of the DataSet as report fields and then push it to the crystal report. Here I am going to explain the PUSH method only.

Steps

  1. Create a new ASP.NET project.

    Sample screenshot

  2. Insert new item as DataSet.

    Sample screenshot

  3. Add elements to the DataSet which you want on the report. Save All, then right click on the DataSet filename in the solution explorer and select command "Build and browse".
  4. Then add a new item to the project as “Crystal report” and insert a blank report.
  5. In the server explorer, right click database field and select database expert and expand the project data and select DataSet in the table selector and press OK.

    Sample screenshot

  6. Then drag the fields from the database fields of server explorer in the detail section of the report. Arrange the fields as you want.

    From the toolbox, add crystal report viewer control on to the page. That will add this variable:

    protected CrystalDecisions.Web.CrystalReportViewer CrystalReportViewer1;
  7. Populate the DataSet. Set the report DataSource and CrystalReportViewer report source.
    private void Page_Load(object sender, System.EventArgs e)
    {
    CrystalReport1 report=new CrystalReport1();
    CrystalReportViewer1.Visible=true;
    DataSet ds=new DataSet("Account");//give same name as on 
    //dataset1 table header
    DataTable table=new DataTable("Account");//give same name as on 
    //dataset1 table header 
    table.Columns.Add("Fname",typeof(System.String));
    table.Columns.Add("Lname",typeof(System.String));
    table.Columns.Add("Salary",typeof(System.String)); 
    DataRow row=table.NewRow();
    row["Fname"]="Mathew";
    row["Lname"]="Hayden";
    row["Salary"]="5000$";
    // add to table
    table.Rows.Add(row);
    ds.Tables.Add(table);
    // set report's dataset
    report.SetDataSource(ds);
    // set report source
    CrystalReportViewer1.ReportSource =report;
    }

    The output will be as follows...

    Sample screenshot

Points to be careful of

  1. Give same names on Dataset and the table element name of inserted DataSet.
  2. As and when you modify DataSet, build it again and log off the current connections in report. Set the DataSource location again pointing to new DataSet, otherwise database fields of the report will not take the change.
  3. Setting up DataBind properties of the report viewer can be avoided. It can be done at runtime.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

Omkar Bhave M
Software Developer (Senior) Autodesk Inc.
United States United States
my name is omkar bhave. I work in Autodesk Inc. USA.

Comments and Discussions

 
GeneralRe: error in this line CrystalReport1 report=new CrystalReport1(); PinmemberVejeeSachi26-Apr-09 16:36 
GeneralRe: error in this line CrystalReport1 report=new CrystalReport1(); Pinmemberashish64198619-May-09 22:40 
GeneralRe: error in this line CrystalReport1 report=new CrystalReport1(); Pinmemberwbeetge23-Feb-10 22:16 
GeneralRe: error in this line CrystalReport1 report=new CrystalReport1(); PinmemberMember 449102731-Mar-11 0:24 
GeneralMY ID [modified] PinmemberJAYRAJ GIRI11-Apr-09 4:04 
Generalcrystal reports PinmemberJAYRAJ GIRI26-Mar-09 21:59 
GeneralDynamically alter the page size of crystal report Pinmemberdilip51411-Mar-09 22:10 
QuestionDataset with multiple tables PinmemberSpunkybabe23-Feb-09 6:53 
QuestionSet Formula field in Crystal report Pinmemberbiswajit nayak15-Nov-08 23:52 
GeneralCrystal report PinmemberAmit S Manekar3-Oct-08 0:06 
Generalcant access the crystalReport PinmemberSlick694-Sep-08 12:27 
QuestionHow to Connect Crystal Report with SQL Server 2000 in VB.Net/ Pinmemberemrugesh18-Aug-08 7:37 
QuestionCan anyone tell me how to upload ASP.NET application with Crystal report on WEB PinmemberAmit Papriwal10-Jul-08 23:14 
QuestionCrystal Report in asp.net 2005 Facing Problem PinmemberGIRISH KUMAR PRAJAPATI9-Jun-08 20:30 
QuestionHow to set a fixed height of Crystal report in asp.net PinmemberJhanvy Thaker7-May-08 22:53 
Questionplease help Pinmembermuthumani12-Feb-08 1:02 
QuestionASP to crystal Reports .rpt NEED HELP Pinmembermjelin26-Apr-07 10:10 
GeneralQuestion adout PUSH model PinmemberDerrick Lasantha12-Mar-07 0:41 
QuestionQuestion Pinmembericeborg24-Jan-07 5:03 
AnswerRe: Question Pinmemberomkar bhave M24-Jan-07 12:16 
Questionicons missing when report is run Pinmembertechie_risa8-Jan-07 20:39 
AnswerRe: icons missing when report is run Pinmembersylvesterg24-Jan-07 5:17 
AnswerRe: icons missing when report is run Pinmemberprabodhbansal5-Feb-07 2:07 
GeneralHelp , asp.net 1.0 with crystal report Pinmemberbeginhs11-Oct-06 17:58 
QuestionCannot get specific Line of code PinmemberGaurav Rathod17-Jul-06 21:34 
GeneralHELP Pinmembermalemsteen2-Jul-06 1:00 
GeneralLogon Problem PinmemberMuneeeb13-Apr-06 22:00 
GeneralKeyup in datagrid in vb.net PinsussAnonymous6-Aug-05 1:48 
GeneralCrystal report In asp.net PinsussAnonymous6-Aug-05 1:40 
GeneralPage Scrolling in Crystal Reports 11 .NET Pinsussbabukabraham@yahoo.com13-Jun-05 6:00 
GeneralCreating Report Dynamically PinmemberDronik10-Apr-05 23:34 
GeneralGood Article Pinmembernorm.net6-Apr-05 5:33 
GeneralPlugging report with Dataset PinsussAnonymous2-Mar-05 12:14 
GeneralCrystal Report in .Net PinsussGeethP1-Mar-05 22:58 
QuestionHow justify report? Pinmembermyanonym23-Feb-05 9:50 
AnswerRe: How justify report? PinsussAnonymous21-Sep-05 15:44 
Generalcrystal report sample PinsussAnonymous25-Nov-04 20:48 
GeneralManually code the dataset and report bind Pinmembercfaulkner1-Nov-04 6:45 
GeneralRe: Manually code the dataset and report bind Pinmemberfrasse5314-Nov-04 19:10 
QuestionIf the report having a sub report, how can I do? PinmemberGoldsunline5-Oct-04 21:10 
GeneralGood article Pinmemberfrasse5320-Sep-04 8:51 
GeneralAll pages in one asp.net PinmemberManish P10-Sep-04 0:11 
GeneralCrystal Reports: DatasourceException Pinmemberspn24-Aug-04 1:46 
GeneralDisplaying images in Crystal report. Pinmembersansav13-Aug-04 0:14 
GeneralUsing more than one datasource. Pinmembersansav12-Aug-04 23:39 
Questionincorrect log on parameters - problem? Pinmemberxienan16-Jun-04 11:50 
AnswerRe: incorrect log on parameters - problem? PinmemberVíctor Sánchez31-Aug-04 0:02 
GeneralReading Ahead PinsussAnonymous20-May-04 10:40 
GeneralRe: Reading Ahead PinsussAnonymous20-May-04 11:30 
GeneralPrinting Reports (ASP.net) PinmemberS P S28-Mar-04 20:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.141223.1 | Last Updated 22 Mar 2003
Article Copyright 2003 by Omkar Bhave M
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid