通过 URL 将参数传递到 SQL Server Reporting Services
我试图在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(9)
首先,请务必将
Reports/Pages/Report.aspx?ItemPath=
替换为ReportServer?
。 换句话说,而不是这样:使用此语法:
可以使用
@ParameterName
在报表中引用或显示参数,无论它们是在报表中还是在 URL 中设置。 您可以使用&ParameterName=Value
将参数附加到 URL。要隐藏显示参数的工具栏,请将
&rc:Toolbar=false
添加到 URL (参考)。将它们放在一起,您可以运行包含嵌入值的 URL,或者将其作为一个报表中的操作调用并由另一报表读取:
在报表的数据集属性查询中:
SELECT stuff FROM view WHERE User = @UserID
在报表中,将表达式值设置为
[UserID]
(或=Fields!UserID.Value
)请记住,如果报表有多个参数,您可能需要在 URL 中包含所有参数(即使为空),具体取决于数据集查询的编写方式。 这意味着同一参数的多个值也会重复参数名称。
要使用 Action = Go to URL 传递参数,请将表达式设置为:
如果后跟 &,请确保表达式后面有一个空格; (换行符是不够的)。 表达式之前不需要空格。 此方法可以传递参数,但不会隐藏它,因为它在 URL 中可见。
如果您不包含
&rs:ClearSession=True
,则在清除浏览器会话缓存之前,报表不会刷新。要使用“操作 = 转到报告”传递参数:
rc:toolbar
); 但是,我认为可以通过报告中的自定义代码读取或设置“提示用户”复选框,如报告服务器参数中所示)作为参考,请参阅 此页面的 URL 编码,例如
/ = %2f
First, be sure to replace
Reports/Pages/Report.aspx?ItemPath=
withReportServer?
. In other words, instead of this:Use this syntax:
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:
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:
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:
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
正如 Shiraz 所说,尝试这样的操作:
请注意,仅当您位于单个文件夹中时,该路径才有效。 当我必须执行此操作时,我只需使用报表服务器路径(“reports”是报表管理器)浏览到报表并复制 url,然后将
&=
添加到结束。As well as what Shiraz said, try something like this:
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.尝试将网址中的“Reports”更改为“ReportServer”
Try changing "Reports" to "ReportServer" in your url
根据 Microsoft,格式基本是:
According to Microsoft, the format basically is:
尝试通过 url 传递多个值:
这应该可行。
Try passing multiple values via url:
This should work.
我通过传递 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
使用下面提到的 URL 在带有动态参数的新窗口中打开报告。
Use the URL, mentioned below to open the report in a new window with dynamic parameters.
尝试将网址中的“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/
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