C # bind data to a crystal report and print data

Source: Internet
Author: User

Steps:

1. Create a new dataset and place the table in the database into DataSet2.xsd.

      

2. Create a New Crystal Report and follow the Wizard to create the Crystal Report, as shown below:

   

3. Create a new WINDOWS form, place a CrystalReportViewer control in the form, click the small triangle row in the upper right corner, select the report to be displayed, and set the report path,

As follows:

  

4. Bind the background code:

  

View source Print? 01 // Start binding 02 String sql= "" 03 sql = "Select * from table name" 04 SqlConnection con= new Sqlconnection( "Data connection string" ); 05 SqlDataApter da= new SqlDataApter(sql,con); 06 DataSet ds= new DataSet(); 07 CrystalReport1  cry= new CrystalReport1 (); 08 con.Open() 09 da.Fill(ds, "dgv" ) 10 cry.SetDataSource(ds.Tables( "dgv" )) 11 CrystalReportViewer1.ReportSource = cry 12 // End binding 13 To implement the print function, you need to modify the following: (This printing function is not included in CrystalReportViewer1 ):View source
Related Article

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.