SSRs configuration on the server

Source: Internet
Author: User
Tags management studio sql server management sql server management studio

SSRs configuration on the server

15:09:41 | category: Default category | Tag: | font size, medium/small subscription

 

There are two ways to configure SSRs on the server. One is to log on to the server through SQL Server Management studio, and the other is to access the server's report manage page through web, such as http: // ip/reports. The functions of the two methods are slightly different. For details about the operation process, refer to the relevant documentation.

Cheng

This section discusses some basic functions of SSRs, namely the creation, release, and reference of reports.

Create report

Design Environment

The report design environment is the business intelligence development studio, which is short for Bi. If the project is carried out in vs2005, It is very convenient, because you can add Bi projects in a solution just like adding a common project. In fact, we did the same.

Basic Steps for creating a report

Before using BI to develop SSRS, we strongly recommend that youAll the related tutorials in line are completed manually.

In general, the design of a report can be summarized into the following steps:

  1. Create a Report Project
  2. Create a data source (DATa source, RDS file), which is a bridge between the report and the database;
  3. Create a dataset, that is, the report data source. The report obtains data from the dataset and does not directly access the database;
  4. Layout)
  5. Preview the result (PreView) and make further modifications based on the results until the requirements are fully met.

Report Publishing

After designing a report, you must publish it to the Reporting Services Service for calling. We can call this release deploy.

After practical application, it is found that there are three methods to publish a report:

Compile and publish in Bi

We designed reports in Bi, which can be used to deploy the entire report project to the server at one time. The procedure is as follows:

  1. Execute project-> properties in the menu, and change configuration to production, that is, edit the parameters in the production mode;
  2. Enter the corresponding attribute values on the right. Generally, the content of targetperformancefolder is Da.Ta sources remains unchanged. If the data source is updated, you must set overwritedatasources to true;
  3. Set targetreportfolder. This value is a virtual directory in the Report Server. All RDL files of the project will be stored in this directory;
  4. Set targetserverurl. Here is the URL of reporting services. For example, http: // localhost/reportserver can be used for local deployment. Note that the following path is the default installation path. After you open the default site in IIS, you can see that it is a virtual directory;
  5. After all are filled in, switch the compiling mode to deploy in the compiling environment and start debugging. Then, Bi will automatically deploy this series of reports to the Report Server.

The http: // localhost/reportserver page is displayed, which displays all reportfolder on the Report Server, and the report is set according to deploy, save them in the folder. After entering folder, click report to view details. The system has generated An ASPX page with reportviewer for us.

Report manager on the Web

The following two methods are used to manage the Report Server. publishing a report is only part of their functions.

The procedure for using report manager is as follows:

  1. Open the report Manager page, which is generally http: // serverurl/reports;
  2. Enter daThe TA Sources folder uploads the RDS file of the data source;
  3. Return to the root folder and create a reportfolder named targetreportfolder;
  4. Enter the folder and upload the RDL files one by one. The report name is automatically named and the default value is generally accepted.

In this way, you can view the content on the reportserver page.

SQL Server Management Studio

In SQL server configuration, this tool is undoubtedly the most powerful. When logging on to SSMs, select "server type" as "reporting services" and specify the server name and logon method. After successful login, the content we see in the report manager is in the home directory. The subsequent operations are similar, so no text is wasted.

Use the reportviewer control to reference a report

The ultimate goal of creating and publishing reports is to reference them in the program. Here we choose the simplest method-use the reportviewer control.

Reportviewer in winform Environment

The reportviewer control under winform is located in the Microsoft. Reporting. winforms namespace. It appears in the toolbar by default in vs2005 and can be operated directly by dragging it into the form.

Generally, the following parameters must be set for all reports:

  • Processingmode: This attribute is used to set whether the reportviewer data source is local or remote. Here we set it to remote;
  • Serverreport. reportserverurl: The targetserverurl we saw earlier, that is, the URL address of the Report Server. Note that this address contains "reportserver", such as http: // serverurl/reportserver;
  • Serverreport. reportpath: A combination of reportfolder and reportname, for example, "/test/report1.rdl". Note that the first "/" must not be omitted!

For practical applications, it is more common to use code to control reportviewer than to set attributes during design. The following is a brief example, which summarizes the process as follows:

This. reportviewer1.serverreport. reportpath = "/test/report1"; List <reportparameter> parameters = new list <reportparameter> (); parameters. add (New reportparameter ("Params", textquerystring. text); this. reportviewer1.serverreport. setparameters (parameters); this. reportviewer1.showparameterprompts = false; this. reportviewer1.refreshreport ();

In the above process, set reportpath first (reportserverurl has been specified in this example, and should actually be set through the setting string of APP. config ). Create a report parameter list (this Params name is the report parameter set during report design, which is referenced by @ Params in an SQL statement) and call the setparameters method of serverreport, pass parameters to the report. Then, set the showparameterprompts attribute of the report to false, that is, the parameter input prompt is not displayed in the reportviewer header. Finally, execute the refreshreport () method to refresh the report page.

Reportviewer in ASP. NET Environment

Microsoft's uniformity work is undoubtedly excellent. The reportviewer in the Web is used exactly the same as that in winform. The only difference is that the control is located in Microsoft. reporting. webforms, and classes such as reportparameter are changed to this namespace. Code control reports can be transplanted without any changes.

Reportviewer in visual webgui

In the project, we use vwg as the framework of the program. The gizmox development team also designed the corresponding version for reportviewer. The control is located in gizmox. webgui. in the reporting namespace, but note that its attributes such as reportparameter and processingmode are still located in Microsoft. reporting. in webforms, do not make a mistake.

Access reports directly through reportserver

Do you still remember the http: // serverurl/reportserver mentioned above? SSRs has prepared a method for viewing reports, that is, access through URL. For example, to view the report1 report under test on the localhost/reportserver server, you can directly enter http: // localhost/reportserver in the browser? Test/report1, SSRs will automatically call a built-in system page to display it. After this URL with parameters, we can control the report by appending URL parameters. For example, in the above example, you can use response. Write () in ASP. NET to write the following code to the page to display the report in the pop-up window:

"<Script language = \" javasWindow. Open ('HTTP: // localhost/reportserver? Test/report1 & Params = "+ textquerystring. Text +" & rc: parameters = false & RS: command = render '; </SCRIPT>"

For the construction method of URL parameters, see the msdn documentation.

Transfer

All of the above are conventional applications, but in fact, most of a report can be done without that example from requirement submission to final deployment, and various problems will be encountered in the middle. In this section, I list the problems and solutions encountered during the development process in different categories and update them continuously.

Deployment and debugging

  • Q: Why does the {user "nt authority \ Network Service" fail to perform this operation when I use reportviewer to load reports in ASP. NET. (Rsaccessdenied)} error?

    A: This is because the access permission to the reportserver virtual directory under IIS is not set correctly. There are three solutions:

    • Access http: // localhost/reports on the server, go to report manager, and click "create role assignment" on the "properties" tab ", in "group or user name", enter "nt authority \ Network Service" (no quotation marks on both sides). Select browser below to confirm. This is to grant this account the permission to browse reports. I strongly recommend this method;
    • In IIS, modify the properties of the reportserver virtual directory under the default site. On the Directory Security tab, click Edit in authentication and access control to enable Anonymous Access, set the anonymous access account to the administrator account, set the local Logon account to administrator, and set the domain account to the domain account with administrator permissions. In this way, you can access the reportserver connection to view the report as an administrator. This is also the most widely spread method on the Internet, but there are serious security risks, there is no problem during development and debugging, and it is not recommended for deployment;
    • Create an anonymous account for reporting services, such as iusr_reportview, assign the browser role to report manager, and perform subsequent steps. This is the most troublesome thing. I am too lazy to write all the steps here. It is also widely spread on the Internet, but I think it will only be used by people who are idle and have nothing to do...
  • Q: I developed vwg in Visual Studio and run it in debug mode. When reportviewer exports a PDF file, the session expired error is reported. What is the problem?

    A: Actually, I don't know why... The solution is to access the site directly in the browser without using debug. As for the reason, we call for an advanced explanation ~~~

Report data

  • Q: I don't just want to pass traditional SQL parameters to reports, such as @ ID, @ count, instead, I want to control the entire WHERE clause and any part of the SQL statement in the form of parameters?

    A: Of course. This is not the case. SSRS is too busy .. A report statement is required here. I have used excel. If the cell value starts with "=", it can be followed by expressions and report statements. The simplest example is as follows:

    1. Choose Report> report parameters from the menu, and add a new parameter. Assume that the name is wherestring of the type, which is a string of other types.
    2. In daModify the dataset of parameters on the TA page. Assume that the content of the original SQL statement is "select * From Table1 where age between 10 and 15 and ID> 40"
    3. Change to = "select * From Table1 where" + parameters! Wherestring. Value
    4. Okay. Switch to preview. Check the result.

    Note that there is a space behind the WHERE clause, especially when constructing an SQL statement.

  1. Q: I did not fill in anything in the parameters prompt box. I directly clicked view report. An error occurred...

    A:-_-| of course, an error occurs. The WHERE clause in the SQL statement has no conditions and the syntax is incorrect .. In this case, you have to make a judgment in the expression statement to check whether the input parameter is null. The above example can be changed:

    = "Select * From Table1" + IIF (parameters! Wherestring. value <> "", "where" + parameters! Wherestring. value ,"")

    Here, IIF is a report statement, which belongs to the program flow statement. For more extensive usage, see the documentation ~~

  2. Q: What should I do if I want to add page x/Page y to a page?

    A: You still need to use the report statement. Go to the Layout View, right-click any text box, and select expr.Ession, that is, the one with the "FX" icon in front, you can see the expression editor. The list in the lower-left box lists the report statement categories. Do you see globals? Click Here and there will be some constants about the report itself on the right. The pagenumber and totalpages are used here. The parameters and IIF parameters used earlier can also be found here. Flexible application of these elements can greatly enrich the expressiveness of reports.

    Oh, forget to mention that both pagenumber and totalpages can only be used at the header or footer. Therefore, before using them, you need to use them in the Layout View, choose Report> page header (or page footer), enable the header or footer, and reference it in it.

  3. Report layout problems

    • Q: Why are my reports horizontally displayed on different pages? I clearly did not cross-border in the design page!

      A: CFT... your eyes have cheated you. The page boundary in the design field has nothing to do with your paper page, and SSRs does not provide the entire page center function. Therefore, you must adjust your page layout a little bit.

      First, we recommend that you change the left and right margin values to 0 on the report-> report properties-> layout tab. Return to the design page and manually specify the locate attribute of the control to determine the size of the Left Border. For example, if the current paper size is A4 (21 cm * 29.7 cm), the total width of my body table is set to 17.75 cm, and the remaining 25cm is the sum of the left and right margins, it is reasonable to say that 1.625 cm should be allocated each, but considering the table line in the table also has a width (I set it to 1pt), the left margin is set to 1.6, that is to say, place the control on the left side of the design page at 6cm, the clear point is to set the value of the left element in the locate attribute of each control on the left to 1.6 .. I didn't mean it ..).

      We recommend that you use the export function of reportviewer to export the data to PDF for preview, and print the data to PDF and XPS. If you are more proud, print the data directly to the paper to see the best. This fine-tuning is a painful process.

    Integration

    After this period of development experience, I personally feel that SSRs is still very useful. It is seamlessly integrated with SQL Server. layout is flexible and changeable, and the powerful functions of the Report Language, coupled with the affinity of Microsoft products, it brings a fresh user experience. However, SSRs execution efficiency is not high. In particular, SSRs of SQL 2005 can only be queried using SQL statements when creating dataset. it is not convenient to implement complicated business logic. In addition, the dynamic Column Display and dynamic page settings need to be improved.

    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.