Simple use of Crystal Reports

Source: Internet
Author: User

PULL Mode
1. Create a dataset: Right-click Project/Add/select dataset/name ds_test/click Add
2. Create a From form Form1
(1) Add a crystalReportViewer1 control to it.
(2) Add the sqlDataAdapter control (automatically generated step by step according to the pop-up Wizard)
(3) generate a dataset Based on the created sqlDataAdapter.
3. Create a report: Right-click Project/Add item/select crystalReport/name CrystalReport1.rpt/click Add
(1) In field resource manager, right-click "database Field"/select "Database Expert"/expand "project data"/expand "ADO. NET dataset"/expand
Add the generated dataset to the right box/OK
(2) Expand "database fields"/expand the following table/drag the fields in the table to the report for Layout Design
4. Define the fromdomainload () event as follows:

Private void Form1_Load (object sender, EventArgs e)
{
// PULL Mode
This. sqlDataAdapter1.Fill (this. ds_test); // ds_test is automatically generated based on the data adapter.
CrystalReport1 cr = new CrystalReport1 ();
Cr. SetDataSource (this. ds_test.Tables [0]);
CrystalReportViewer1.ReportSource = cr;
}

 

PUSH mode
1. Create a dataset: Right-click Project/Add/select dataset/name ds_test/click Add
2. Create a From form Form1
(1) Add a crystalReportViewer1 control to it.
(2) Add the sqlDataAdapter control (automatically generated step by step according to the pop-up Wizard)
(3) generate a dataset Based on the created sqlDataAdapter.
3. Create a report: Right-click Project/Add item/select crystalReport/name CrystalReport1.rpt/click Add
(1) In field resource manager, right-click "database Field"/select "Database Expert"/expand "project data"/expand "ADO. NET dataset"/expand
Add the generated dataset ds_test to the right box/OK
(2) Expand "database fields"/expand the following table/drag the fields in the table to the report for Layout Design
4. Define the fromdomainload () event as follows:

SqlConnection conn = new SqlConnection ("server =; integrated security = sspi; database = ");
SqlDataAdapter da;
DataSet ds = new DataSet ();
Private void Form1_Load (object sender, EventArgs e)
{
// PUSH mode
Da = new SqlDataAdapter ("SQL query statement", conn );
Da. Fill (ds );
CrystalReport1 cr = new crystalReport1 ();
Cr. SetDataSource (ds. Tables [0]);
CrystalReportView1.ReportSource = cr;

}

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.