通过 URL 将参数传递到 SQL Server Reporting Services

发布于 2024-07-25 21:46:25 字数 293 浏览 8 评论 0原文

我试图在 URL 中传递一个 userId (字符串),该 URL 将传递到数据库并由 SSRS 中的查询使用。

基本网址:

http://blah/Reports/Pages/Report.aspx?ItemPath=MyReport

我尝试过这个,但它不起作用:

http://blah/Reports/Pages/Report.aspx?ItemPath=MyReport&UserId=fred

有什么想法吗?

I'm trying to pass a userId (string) in the URL which will be passed to the database and used by a query in SSRS.

base URL:

http://blah/Reports/Pages/Report.aspx?ItemPath=MyReport

I tried this, but it doesn't work:

http://blah/Reports/Pages/Report.aspx?ItemPath=MyReport&UserId=fred

Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(9

江湖正好 2024-08-01 21:46:25

首先,请务必将 Reports/Pages/Report.aspx?ItemPath= 替换为 ReportServer?。 换句话说,而不是这样:

http://server/Reports/Pages/Report.aspx?ItemPath=/ReportFolder/ReportSubfolder/ReportName

使用此语法:

http://server/ReportServer?/ReportFolder/ReportSubfolder/ReportName

可以使用 @ParameterName 在报表中引用或显示参数,无论它们是在报表中还是在 URL 中设置。 您可以使用 &ParameterName=Value 将参数附加到 URL。

要隐藏显示参数的工具栏,请将 &rc:Toolbar=false 添加到 URL (参考)。

将它们放在一起,您可以运行包含嵌入值的 URL,或者将其作为一个报表中的操作调用并由另一报表读取:

http://server.domain.com/ReportServer?/ReportFolder1/ReportSubfolder1/ReportName&UserID=ABC123&rc:Toolbar=false

在报表的数据集属性查询中:SELECT stuff FROM view WHERE User = @UserID

在报表中,将表达式值设置为 [UserID](或 =Fields!UserID.Value

请记住,如果报表有多个参数,您可能需要在 URL 中包含所有参数(即使为空),具体取决于数据集查询的编写方式。 这意味着同一参数的多个值也会重复参数名称。

要使用 Action = Go to URL 传递参数,请将表达式设置为:

="http://server.domain.com/ReportServer?/ReportFolder1/ReportSubfolder1/ReportName&UserID="
 &Fields!UserID.Value 
 &"&rc:Toolbar=false"
 &"&rs:ClearSession=True"

如果后跟 &,请确保表达式后面有一个空格; (换行符是不够的)。 表达式之前不需要空格。 此方法可以传递参数,但不会隐藏它,因为它在 URL 中可见。

如果您不包含 &rs:ClearSession=True,则在清除浏览器会话缓存之前,报表不会刷新。

要使用“操作 = 转到报告”传递参数:

  • 指定报告
  • 添加参数以运行报告
  • 添加您希望传递的参数(这些参数需要在目标报告中定义,因此据我所知,您可以使用此方法时,不要使用特定于 URL 的命令,例如 rc:toolbar); 但是,我认为可以通过报告中的自定义代码读取或设置“提示用户”复选框,如报告服务器参数中所示)

作为参考,请参阅 此页面的 URL 编码,例如 / = %2f

First, be sure to replace Reports/Pages/Report.aspx?ItemPath= with ReportServer?. In other words, instead of this:

http://server/Reports/Pages/Report.aspx?ItemPath=/ReportFolder/ReportSubfolder/ReportName

Use this syntax:

http://server/ReportServer?/ReportFolder/ReportSubfolder/ReportName

Parameters can be referenced or displayed in a report using @ParameterName, whether they're set in the report or in the URL. You can attach parameters to the URL with &ParameterName=Value.

To hide the toolbar where parameters are displayed, add &rc:Toolbar=false to the URL (reference).

Putting that together, you can run a URL with embedded values, or call this as an action from one report and read by another report:

http://server.domain.com/ReportServer?/ReportFolder1/ReportSubfolder1/ReportName&UserID=ABC123&rc:Toolbar=false

In the report's dataset properties query: SELECT stuff FROM view WHERE User = @UserID

In the report, set the expression value to [UserID] (or =Fields!UserID.Value)

Keep in mind that if a report has multiple parameters, you might need to include all parameters in the URL, even if blank, depending on how your dataset query is written. That means repeating the parameter name for multiple values of the same parameter, too.

To pass a parameter using Action = Go to URL, set expression to:

="http://server.domain.com/ReportServer?/ReportFolder1/ReportSubfolder1/ReportName&UserID="
 &Fields!UserID.Value 
 &"&rc:Toolbar=false"
 &"&rs:ClearSession=True"

Be sure to have a space after an expression if followed by & (a line break is isn't enough). No space is required before an expression. This method can pass a parameter but does not hide it as it is visible in the URL.

If you don't include &rs:ClearSession=True then the report won't refresh until browser session cache is cleared.

To pass a parameter using Action = Go to report:

  • Specify the report
  • Add parameter(s) to run the report
  • Add parameter(s) you wish to pass (the parameters need to be defined in the destination report, so to my knowledge you can't use URL-specific commands such as rc:toolbar using this method); however, I suppose it would be possible to read or set the Prompt User checkbox, as seen in reporting sever parameters, through custom code in the report)

For reference, see this page on URL encoding, e.g. / = %2f

兔小萌 2024-08-01 21:46:25

正如 Shiraz 所说,尝试这样的操作:

http://<server>/ReportServer/Pages/ReportViewer.aspx?%2f<path>%2f<ReportName>&rs:Command=Render&UserID='fred'

请注意,仅当您位于单个文件夹中时,该路径才有效。 当我必须执行此操作时,我只需使用报表服务器路径(“reports”是报表管理器)浏览到报表并复制 url,然后将 &= 添加到结束。

As well as what Shiraz said, try something like this:

http://<server>/ReportServer/Pages/ReportViewer.aspx?%2f<path>%2f<ReportName>&rs:Command=Render&UserID='fred'

Note the path would only work if you are in a single folder. When I have to do this I simply browse to the report using the reportserver path ("reports" is the report manager) and copy the url then add &<ParameterName>=<value> to the end.

倾城泪 2024-08-01 21:46:25

尝试将网址中的“Reports”更改为“ReportServer”

Try changing "Reports" to "ReportServer" in your url

杀手六號 2024-08-01 21:46:25

根据 Microsoft,格式基本是:

http://<server>/reportserver?/<path>/<report>&rs:Command=Render&<parameter>=<value>

According to Microsoft, the format basically is:

http://<server>/reportserver?/<path>/<report>&rs:Command=Render&<parameter>=<value>
一笔一画续写前缘 2024-08-01 21:46:25

尝试通过 url 传递多个值:

/ReportServer?%2fService+Specific+Reports%2fFilings%2fDrillDown%2f&StartDate=01/01/2010&EndDate=01/05/2010&statuses=1&statuses=2&rs%3AFormat=PDF

这应该可行。

Try passing multiple values via url:

/ReportServer?%2fService+Specific+Reports%2fFilings%2fDrillDown%2f&StartDate=01/01/2010&EndDate=01/05/2010&statuses=1&statuses=2&rs%3AFormat=PDF

This should work.

つ低調成傷 2024-08-01 21:46:25

我通过传递 URL 中可用参数的值而不是参数的标签解决了类似的问题。

例如,我有一个带有名为 viewName 的参数的报表,该参数的预定义可用值为:(标签/值)orders/sub_orders、orderDetail/sub_orderDetail、product/sub_product。

要使用 URL 调用此报告以自动呈现参数 = 产品,您必须指定值而不是标签。
这是错误的:
http://server/reportserver?/Data+Dictionary/DetailedInfo& ;viewName=product&rs:Command=Render

这是正确的:
http://server/reportserver?/Data+Dictionary/DetailedInfo& ;viewName=sub_product&rs:Command=Render

I solved a similar problem by passing the value of the available parameter in the URL instead of the label of the parameter.

For instance, I have a report with a parameter named viewName and the predefined Available Values for the parameter are: (labels/values) orders/sub_orders, orderDetail/sub_orderDetail, product/sub_product.

To call this report with a URL to render automatically for parameter=product, you must specify the value not the label.
This would be wrong:
http://server/reportserver?/Data+Dictionary/DetailedInfo&viewName=product&rs:Command=Render

This is correct:
http://server/reportserver?/Data+Dictionary/DetailedInfo&viewName=sub_product&rs:Command=Render

最美不过初阳 2024-08-01 21:46:25

使用下面提到的 URL 在带有动态参数的新窗口中打开报告。

="javascript:void(window.open('http://Servername/ReportServer?/Foldername/Reportname&rs:Commnd=Render¶meter1=" & Fields!A.Value & "¶meter2=" & Fields!B.Value & "'))"

Use the URL, mentioned below to open the report in a new window with dynamic parameters.

="javascript:void(window.open('http://Servername/ReportServer?/Foldername/Reportname&rs:Commnd=Render¶meter1=" & Fields!A.Value & "¶meter2=" & Fields!B.Value & "'))"
小兔几 2024-08-01 21:46:25

尝试将网址中的“Reports”更改为“ReportServer”。
为此,只需访问此http://host/ReportServer/,然后您就可以转到报告页面。 像这样附加你的参数
&=

有关更多详细信息:

http://dobrzanski.net/2008/08/11/reporting-services-problem-with-passing-parameters-directly-in- the-url/

https://www.mssqltips.com/sqlservertip/1336/pass-parameters-and-options-with-a-url-in-sql-reporting-services/

Try changing "Reports" to "ReportServer" in your url.
For that just access this http://host/ReportServer/ and from there you can go to the report pages. There append your parmaters like this
&<parameter>=<value>

For more detailed information:

http://dobrzanski.net/2008/08/11/reporting-services-problem-with-passing-parameters-directly-in-the-url/

https://www.mssqltips.com/sqlservertip/1336/pass-parameters-and-options-with-a-url-in-sql-reporting-services/

场罚期间 2024-08-01 21:46:25

http://desktop-qr277sp/Reports01/report/Reports/reportName?Log%In%Name=serverUsername¶mName=value

通过服务器身份验证将参数传递给报表

http://desktop-qr277sp/Reports01/report/Reports/reportName?Log%In%Name=serverUsername¶mName=value

Pass parameter to the report with server authentication

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文