In the previous article, I wrote a usageActivereport for. netThe simplest exampleActivereportHow to bind a data source
1. Create a table first Chartingtable , There are two fields, Onlineusercount , Project , Generated through the wizard Dataset And drag and drop to generate Tableadapter .
2. Next, design the display format in the report designer. Pageheader Put two Label Project and online users respectively ". In Detail Two corresponding zones Label , Respectively set Datafiled Is Project And Onlineusercount , You will see the two Label The content of the corresponding field is displayed.
3. You can specify Dataset Or Dataview As a data source, the following shows how to set a data source for a report:
UseDataset:
This. Chartingtabletableadapter. Fill (This. Dataset1.chartingtable );
Rpt. datasource =This. Dataset1;
Rpt. datamember =This. Dataset1.chartingtable. tablename;
Rpt. Run ();
This. Viewer1.document = Rpt. Document;
UseDataview:
This. Chartingtabletableadapter. Fill (This. Dataset1.chartingtable );
DataviewDV =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 report designer'sDetailThere is a small icon like a database in the header. 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.