Use ActiveReport for. net for report development (2)-bind a data source)

Source: Internet
Author: User

In the previous article, I wrote a simple example of using ActiveReport for. net. This article will demonstrate how to bind a data source in ActiveReport.

 

1. Create a chartingTable table with two fields: OnlineUserCount and Project. Generate a DataSet using the wizard and drag and drop the TableAdapter.

2. design the display format in the report designer. Put two labels in the PageHeader: "project" and "online users ". In the Detail area, set DataFiled to Project and OnlineUserCount respectively. During the operation, the two labels show the content of the corresponding fields.

3. You can specify DataSet or DataView as the data source for the report. The following shows how to set a data source for the report:

Use DataSet:

This. chartingTableTableAdapter. Fill (this. dataSet1.ChartingTable );

Rpt. DataSource = this. dataSet1;

Rpt. DataMember = this. dataSet1.ChartingTable. TableName;

Rpt. Run ();

This. viewer1.Document = rpt. Document;

Use DataView:

This. chartingTableTableAdapter. Fill (this. dataSet1.ChartingTable );

DataView dv = this. dataSet1.ChartingTable. DefaultView ;;

Rpt. DataSource = dv;

Dv. RowFilter = "project = '1 '";

Rpt. Run ();

This. viewer1.Document = rpt. Document;

4. You can also use the report designer to specify a data source for the report.

In the header of the Detail part of the Report designer, there is a small icon like a database. Click it and a wizard will appear. Follow the Wizard to connect to the database step by step and define the query.

 

The preceding example shows how to bind a dataset as a data source. However, an object set is often used as a data source in a project. The next example shows how to display data in an object set in a report.

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.