Crystal reports in ASP.NET (medium)

xiaoxiao2021-03-06  15

Use PULL mode

We will pass the following steps to perform crystal reports through the PULL mode.

1. First create the RPT file and set some must-have data connections using the Crystal Report Design Interface.

2. Drag and drop a CrystalReportViewer control to the ASPX page, set its properties to specify the.rpt file we created in the previous step.

3. Call the DataBind method in the code.

Create a .rpt file:

1) On right-click "Solution Over", select "Add" - Add New Items in the pop-up menu -> "Crystal Report" -> "Crystal Report"

2) Select "As the Blank Report" radio button in the Crystal Report Library, and finally click OK.

3) The crystal report designer will pop up here.

4) Right-click Details Zone, select "Database" -> "Add / Delete Database ..."

5) In the "Database Expert" pop-up, the OLE DB (ADO "option is expanded, and another" OLE DB (ADO) window will pop up.

6) In the OLE DB (ADO "pop-up window, select" Microsoft Ole DB Provider for SQL Server "and" Next "

7) Specify the information of the connection

Server: ASPCN (What is your machine written? What is your name? User ID: SA password: Database

8) Click "Next" and finally click the "Finish" button.

9) At this point you can see the database we have selected in the Database Expert window.

10) Extend the "PUBS" database, extend the "table", select the "Stores" table and add it to the "Selected Table" area, click the "OK" button.

11) Now displaying the table you selected in the "Database Field" area in the Field Source Browser, as well as the fields in the table.

12) Drag and drop the desired field to enter the "Detail" area of ​​the report. The field name will automatically appear in the "Header" area. If you want to modify the header, you can right-click the text in the Header area, select the Edit Text Object option and edit.

13) Save so that we have a crystal report file.

Create a CrystalReportViewer control

14) Go back to WebForm, drag and drop a Crystal Report Viewer control to the page.

15) Tune the properties window of the Crystal Report Viewer control, select the "DataBindings" area Click [...]

16) In "Crystal Report Viewer Data Binding Window", select "ReportSource" in the "Bonitable Properties" on the right, and select the "Custom Binding Expression" in the lower right corner to specify the .rpt file path.

17) At this point you can see the preview of report files that use some virtual data in the Crystal Report Viewer control.

Note: In the above example, CrystalReportViewer can call real data directly when design, because the data has been saved. In this case, when the data is not saved, he cannot display data when it is not saved. Instead, this is to show some virtual data, and only real data is selected only when executed.

Code Behind program design

18) Call the DataBind method in the Page_Load method.

Execute your program

19) Create and run your program!

You can now use some of the features built into the WEB page, such as page navigation, zoom, and so on.

We will pass the following steps to perform crystal reports through the PULL mode.

1. First create the RPT file and set some must-have data connections using the Crystal Report Design Interface.

2. Drag and drop a CrystalReportViewer control to the ASPX page, set its properties to specify the.rpt file we created in the previous step. 3. Call the DataBind method in the code.

Create a .rpt file:

1) On right-click "Solution Over", select "Add" - Add New Items in the pop-up menu -> "Crystal Report" -> "Crystal Report"

2) Select "As the Blank Report" radio button in the Crystal Report Library, and finally click OK.

3) The crystal report designer will pop up here.

4) Right-click Details Zone, select "Database" -> "Add / Delete Database ..."

5) In the "Database Expert" pop-up, the OLE DB (ADO "option is expanded, and another" OLE DB (ADO) window will pop up.

6) In the OLE DB (ADO "pop-up window, select" Microsoft Ole DB Provider for SQL Server "and" Next "

7) Specify the information of the connection

Server: ASPCN (What is your machine written? What is your name? User ID: SA password: Database

8) Click "Next" and finally click the "Finish" button.

9) At this point you can see the database we have selected in the Database Expert window.

10) Extend the "PUBS" database, extend the "table", select the "Stores" table and add it to the "Selected Table" area, click the "OK" button.

11) Now displaying the table you selected in the "Database Field" area in the Field Source Browser, as well as the fields in the table.

12) Drag and drop the desired field to enter the "Detail" area of ​​the report. The field name will automatically appear in the "Header" area. If you want to modify the header, you can right-click the text in the Header area, select the Edit Text Object option and edit.

13) Save so that we have a crystal report file.

Create a CrystalReportViewer control

14) Go back to WebForm, drag and drop a Crystal Report Viewer control to the page.

15) Tune the properties window of the Crystal Report Viewer control, select the "DataBindings" area Click [...]

16) In "Crystal Report Viewer Data Binding Window", select "ReportSource" in the "Bonitable Properties" on the right, and select the "Custom Binding Expression" in the lower right corner to specify the .rpt file path.

17) At this point you can see the preview of report files that use some virtual data in the Crystal Report Viewer control.

Note: In the above example, CrystalReportViewer can call real data directly when design, because the data has been saved. In this case, when the data is not saved, he cannot display data when it is not saved. Instead, this is to show some virtual data, and only real data is selected only when executed.

Code Behind program design

18) Call the DataBind method in the Page_Load method.

Execute your program

19) Create and run your program!

You can now use some of the features built into the WEB page, such as page navigation, zoom, and so on.

We will pass the following steps to perform crystal reports through the PULL mode.

1. First create the RPT file and set some must-have data connections using the Crystal Report Design Interface.

2. Drag and drop a CrystalReportViewer control to the ASPX page, set its properties to specify the.rpt file we created in the previous step.

3. Call the DataBind method in the code.

Create a .rpt file:

1) On right-click "Solution Overview", select "Add" - Add New Items "->" Crystal Report "2) in the" Crystal Report Library "in the" Crystal Report Library ". Single selection button, finally click OK.

3) The crystal report designer will pop up here.

4) Right-click Details Zone, select "Database" -> "Add / Delete Database ..."

5) In the "Database Expert" pop-up, the OLE DB (ADO "option is expanded, and another" OLE DB (ADO) window will pop up.

6) In the OLE DB (ADO "pop-up window, select" Microsoft Ole DB Provider for SQL Server "and" Next "

7) Specify the information of the connection

Server: ASPCN (What is your machine written? What is your name? User ID: SA password: Database

8) Click "Next" and finally click the "Finish" button.

9) At this point you can see the database we have selected in the Database Expert window.

10) Extend the "PUBS" database, extend the "table", select the "Stores" table and add it to the "Selected Table" area, click the "OK" button.

11) Now displaying the table you selected in the "Database Field" area in the Field Source Browser, as well as the fields in the table.

12) Drag and drop the desired field to enter the "Detail" area of ​​the report. The field name will automatically appear in the "Header" area. If you want to modify the header, you can right-click the text in the Header area, select the Edit Text Object option and edit.

13) Save so that we have a crystal report file.

Create a CrystalReportViewer control

14) Go back to WebForm, drag and drop a Crystal Report Viewer control to the page.

15) Tune the properties window of the Crystal Report Viewer control, select the "DataBindings" area Click [...]

16) In "Crystal Report Viewer Data Binding Window", select "ReportSource" in the "Bonitable Properties" on the right, and select the "Custom Binding Expression" in the lower right corner to specify the .rpt file path.

17) At this point you can see the preview of report files that use some virtual data in the Crystal Report Viewer control.

Note: In the above example, CrystalReportViewer can call real data directly when design, because the data has been saved. In this case, when the data is not saved, he cannot display data when it is not saved. Instead, this is to show some virtual data, and only real data is selected only when executed.

Code Behind program design

18) Call the DataBind method in the Page_Load method.

Execute your program

19) Create and run your program!

You can now use some of the features built into the WEB page, such as page navigation, zoom, and so on.

转载请注明原文地址:https://www.9cbs.com/read-45855.html

New Post(0)