Crystal report.net Web Report Development Diary (II)

Source: Internet
Author: User
Some preliminary knowledge of the Web using Crystal report.net for development:

Execution mode
Crystal Report data can be implemented using the following methods:
Pull mode:
When requested, the Crystal Report connects the database directly to the specified drive and assembles the data.
Push mode:
At this point, you have to write your own code to connect the data and assemble the dataset, and send it to the report. In some cases, you can use report performance maximization by using Connection Sharing and limiting the size of the record collection.

Report type:
Crystal Report Designer can also use separate report objects by directly including reports to the project.
Strongly-typed Report:
When you add a report file to a project, it becomes a "strongly-typed" report. In these cases, you will have the power to directly create the report object, which will reduce some code and provide some performance.
Un-typed Report:
The reports here are not directly included in the project, so they are called ' un-typed ' reports. In this case, you have to use the Crystal Report "Reportdocuemt" object to create an instance, and "Manually" to the use of the report.

Other matters for attention
Although the Crystal Report Viewer has some cool features, such as scaling, page navigation, and so on. But he doesn't provide the print function, you have to call the browser's print function.
Vs. NET in the Crystal Report if not registered, then it can only use 30 times, 30 times, the "save" function can no longer use. To avoid this, you are not registering this product in http://www.crystaldecisions.com/. (as if not, not registered also seems to be able to use a long time, but can not provide support)
The default installed Crystal Report can only support 5 users, and in order to support more users, you have to purchase licenses in http://www.crystaldecisions.com/.



I am using the push mode in the actual development application: Because the general table pattern is simpler and can be completely replaced in the Web development, I use the actual development of the graphical report as an example.

The development steps are as follows:
1, create a dataset in the project, then right-click-> Select "New element", the name of the element is the name of the datasheet.
The dataset name is tentatively set to: Reportdata,element is the equivalent of a datasheet, which is tentatively named: DataTable, next to Element
Add the field, which is the data we want to use in our report. Note the field type.

2, draw an empty Crystal Report file (*.RPT), and then, in the report drawing interface Right-click-> Select "Database-> Add/Remove database" Open "database Expert", select "Project Data->ado.net DataSet", You will see the element dataset ReportData you just created, using a DataTable as the report data. Next, insert the chart with the report expert, using the data fields in the DataTable
To generate the data for the report.

3, create a Web form, put a Crystalreportviewer control on the form! Write code gets the dataset that fills a defined dataset and then generates a "object for a report file" that points the object's data source to a dataset that has populated the data, and assigns the ReportSource property of the Crystalreportviewer control equal to the generated Object of the report file, the Visible property of the Crystalreportviewer control is set to true;

Code considerations:
1. The name of the table that fills the data in the dataset must be the same as the element originally defined, otherwise the report will be blank
2, the field that fills the DataSet data table also wants and element definition field attribute, the name is consistent!
Like what:
There are two defined fields in the element: EntryName string, entrysales decimal

The SQL statement that fills the dataset,
Select B.item_name as EntryName, Sum (A.expend_money) as Entrysales from T_ware_sales ....


Complete the above 3 steps, you can see in IE on your web graphics report, in fact, is crystal generated a picture!
Done!

Next chapter, I'll use my own code to explain the whole process in detail. But if you are familiar with. NET development according to what I have described in this section, it should be no problem!



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.