Crystal report-getting started

Source: Internet
Author: User

The crystal report has two modes: pull and push. This article uses the push mode in the web project;

Reports simulate product orders, involving three tables: product, productorder, and client.

1. Create a design-time dataset and establish the link before the table in Database Expert, such:

2. Create a. rpt file and point to the dataset we created earlier. The name is pullcrystalreport3.rpt, for example:

3. Place the Crystal Report viewer control on the. ASPX page.

 

<% @ Page Language = "C #" autoeventwireup = "true" codefile = "pull3.aspx. CS "inherits =" pull3 "%> <% @ register Assembly =" crystaldecisions. web, version = 10.5.3700.0, culture = neutral, publickeytoken = 692fbea5521e1304 "namespace =" crystaldecisions. web "tagprefix =" cr "%> <! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <HTML xmlns = "http://www.w3.org/1999/xhtml">  


4. Add the following to code behind page:Code:

 

 

Dataset DS = new dataset (); sqldataadapter da = new sqldataadapter (); string connectionstr = "Data Source = .; initial catalog = crystalreport; persist Security info = true; user id = sa; Password = 111 "; sqlconnection connection = new sqlconnection (connectionstr ); // set the data source da = new sqldataadapter ("select * from client", connection); DA. fill (DS, "client"); da = new sqldataadapter ("select * from product", connecti On); DA. fill (DS, "product"); da = new sqldataadapter ("select * From productorder", connection); DA. fill (DS, "productorder"); // sets the report document string reportpath = server. mappath ("~ /Pullcrystalreport3.rpt "); reportdocument RPT = new reportdocument (); Rpt. Load (reportpath); Rpt. setdatasource (DS); // specify the data source crystalreportviewer as crystalreportviewer1.reportsource = RPT;

5. The final effect is as follows:

 

 

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.