In Visual Studio. NET using Crystal (middle)

Source: Internet
Author: User
Tags header ole visual studio
Visual in the Visual Studio. NET used in Crystal (China )



From www.aspfree.com
Translated by Cash (world seventh)
Cashcao@msn.com (cashcao@msn.com)



Crystal Demo-Use Pull Model



We can use the following steps to implement the pull model of Crystal Reports:



(1) Create a. rpt file and set up the necessary database joins.

(2) Place crystalreportviewer control on the. aspx page and set its properties to point to the. rpt file that we created.

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



Creating. rpt Files :



1 Right click Solution Explorer, select "Add"--> "Add new Item"--> "Crystal", add a new Crystal file.







2 in the "Crystal Gallery" pop-up window, select the "as a Blank" button and click OK.









3) This will open a new report file on Crystal Reports Designer







4 in the Report "Details section" on the right click, select "Database"-> "Add/remove database."



5 in the Database Expert window, expand the OLE DB (ADO) option, and a new OLE DB (ADO) window will open.



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" to Finish.



9 Now you can see that the database expert shows that the table is selected.



10 Expand the "pubs" library, expand "Tables", select the "Stores" table and ">" to include it in "Selected tables."







11 The field explore will now be displayed in the "Database Fields".

12 Drag the required fields into the details section of the table. The name of this field will automatically appear in the Page header section. If you want to change the header text, right-click the text in the page header, select "Edit Text Object" and edit it.







13) Save, we will use it in the future.



Create a Crystal the Viewer control



14) Return to our Web Form page and drag a "Crystal the Viewer" control to the page from "WebForms" tool box.



15 Select DataBindings in the Properties window and click [...]



16 in the "Crystal" Viewer Databinding window, select "Source", select "Custom Binding Expression", type the path of the. rpt file you just saved (note double quotes )。







17 Now you can see Crystal the show viewer showing a preview.



Note: In the previous example, the Crystal Report Viewer control was able to display the data directly because it was stored with the data. In this case, however, it is not shown directly at design time, because the report does not contain relevant data and is replaced by pseudo data at design time, only when Run-time data is displayed.



Change behind Page Code



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.









Notice that you can use a control like "Page navigation", "Zoom", and so on.

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.