Use crystal report (medium) in Visual Studio. NET)

Source: Internet
Author: User
Crystal Report demo-Use pull Model

Follow these steps to use the PULL model of Crystal Reports:

(1) create a. rpt file and set the necessary database connection.

(2) Place the crystalreportviewer control on the. ASPX page and set its attributes to point to the. rpt file we created.

(3) Call the databind method in your code behind page file.

Create a. rpt file:

1) Right-click Solution Explorer and choose "add" --> "Add new item" --> "Crystal Report" to add a new crystal report file.

2) In the "Crystal Report Gallery" pop-up window, select the "as a blank report" button and click "OK ".

3) This will open a new report file on the crystal report designer.


4) Right-click the "details section" of the report and choose "Database"-> "Add/Remove Database ".

5) in the "Database Expert" window, expand the "ole db (ADO)" option to open a new "ole db (ADO)" window.

6) in the "ole db (ADO)" window, select "Microsoft ole db provider for SQL Server" and click "Next ".

7) Specify the connection information as follows:

Server: homepc (name of your server)
User ID: SA
Password:
Database: pubs

8) Click "Next" and finish.

9) Now you can see that Database Expert shows that the table is selected.

10) Expand the "pubs" database, expand "tables", select "stores" table, and include it with ">" into "Selected tables ".

11) Now field fields e will be displayed in "database fields.

12) drag the required fields into the details section of the table. The field name will automatically appear in the page header section. If you want to modify the header text, right-click the text in the page header section, select "edit text object" and edit it.

13) Save and we will use it later.
Create a crystal report viewer Control

14) return to our web form page and drag a "Crystal Report viewer" control from "webforms" tool box to the page.

15) in the Properties window, select databindings and click [...]

16) in the "Crystal Report viewer databinding" window, select "report source", select "custom binding expression", and type the one you saved. path of the rpt file (double quotation marks ).

17) Now you can see that the crystal report viewer shows a preview.

Note: In the previous example, the crystal report viewer control can directly display data because the report is stored together with the data. However, in this example, it will not be directly displayed during design, because the report does not contain relevant data and is replaced by pseudo data during design, data is displayed only when running.

Change behind pageCode

18) Open the code behind file and add the databind Method to the page load event.

Run

19) Press F5 to run the viewing effect.

Note that you can use controls that come with this report, such as "page navigation" and "zoom.

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.