3

I have a requirement to create dynamic connection for SSRS reports where the connection information (Server & DB) will be worked out in c# code, so no interaction with end user selecting(Server or DB).

Catch here is report on its load will connect to specified DB and then populate the several other parameters like dropdowns etc at runtime using current connection.

For same i went down the route of Expression based connection string in SSRS. It all works well till i keep the "Dynamic" connection parameter type "Visible" and during report run pass the connection string from frontend which is not what i want.

How can i run report with dynamic connection from backend and then populate other parameters on report load itself?

4

2 回答 2

2

好的,我想出了如何做到这一点...我在报表服务器上做正确的事情(设置参数,可见性等)但是在通知报表服务在当前报表执行期间包含新参数值时出错,所以参数值设置正确,但不是当前执行周期的一部分。

为了实现这一点,我在 SSRS http://technet.microsoft.com/en-us/library/reportexecution2005.reportexecutionservice.loadreport2.aspx的 ReportExecutionService 上调用了 LoadReport2 方法

这将返回包含当前报告的 ExecutionId 的 ExecutionInfo2

http://technet.microsoft.com/en-us/library/reportexecution2005.executioninfo2.aspx

使用此 ExecutionId 并仅为我想更改的参数(在我的情况下为动态连接字符串参数)设置值,调用 SSRS 报告服务的 SetExecutionParameters2

SetExecutionParameters2(executionId, new ServiceValues{Name & Value})

http://technet.microsoft.com/en-us/library/reportexecution2005.reportexecutionservice.setexecutionparameters2.aspx

现在报告按预期运行,动态连接参数为隐藏,没有默认值,并且还使用动态连接在报告上加载相关参数:)

再次感谢 Irb 和 Ian 的投入

于 2013-09-12T11:11:23.860 回答
1

在您的报告数据源中添加类似于以下内容的连接字符串:

="Data Source="+Parameters!DatabaseServerName.Value+";Initial Catalog="&Parameters!DatabaseName.Value

然后将这两个参数添加到您的报告中。您需要在服务器上预先建立数据源凭据才能使其正常工作。

于 2013-09-10T02:33:23.497 回答