SQL Reporting Services solves the confusion of passing parameters directly and using reportviewer to present reports

Source: Internet
Author: User
A few days ago, I accidentally went to odetocode.com and saw several articles about SQL reporting services, which is very enlightening. So I studied these articles in conjunction with the online series of reporting services, my confusion is solved for the moment.
You can directly pass parameters to the. ASPX page (use the reportviewer control to present the report) and accept parameters on the. ASPX page to present the required report. The main solution is as follows:

1. Use vs.net to open the reportviewer project. The project folder is in the related folder of SQL reporting services you have installed (see figure 1 ).

2. Open the reportviewer. CS file, write the following method (see figure 2), and re-compile the project.

3. Create a report file RDL with parameters. For details, refer to my previous articles.

4. Create a New. aspx file, reference and compile reportviewer. dll, and drag the control to the. ASPX page (see figure 3 ),

You can directly set the report path, report server path, and related attributes in the reportviewer attribute bar, or set the code in. aspx. CS page_load (see figure 4 ).

5. To test the passing parameters, create an HTM page and add a link to the connection (see figure 5 ).

6. In the. aspx. CS code, the received parameters are accepted and passed to the report. This uses the method shown in Figure 2 (see figure 6 ).

7. After running the task, you can get the Report of the parameters you have passed (see figure 7). The preceding query parameter box is not displayed because the parameters in the reportviewer attribute is set to false, which makes the interface better.

To sum up, we can add other similar methods to achieve our desired results. If you want to pass two or three values, the method is the same. You only need to set two or three parameters in the report file. In addition, the question about export and printing can be found in. set the export format directly in the CS code, such as this. reportviewer1.format = "pdf"; then the page will be opened directly with Acrobat.
The above is purely personal experience. If you have any mistakes, please correct them and we welcome you to discuss them together.

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.