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.