动态更改 Sql Reporting Services 2008 中的数据源

发布于 2024-12-27 23:30:06 字数 159 浏览 2 评论 0原文

我想使用相同的 Reports(.rdl) 生成 24 个数据库的报告。

例如,如果我的报告(.rdl)中有一个用户表,那么报告(.rdl)的数据源应该动态更改。现在,我正在为 24 个数据库制作 24 份不同的报告。

我想要一个在运行时更改数据源的单个报告(.rdl)。

I want to use the same Reports(.rdl) to generate the reports for 24 databases.

For instance if there is a user table in my reports(.rdl), then the datasource for the report(.rdl) should change dynamically. Now, I'm making 24 different Reports for 24 databases.

I want a single report(.rdl) with the datasource changed at the runtime.

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

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

发布评论

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

评论(2

迟月 2025-01-03 23:30:06

实现此目的的方法可以是向报告 (.rdl) 文件添加 3 个参数

服务器名称

数据库名称

以及如果需要

密码

然后更改数据源的连接字符串,例如

="数据源=" &参数!ServerName.Value & “;初始目录=”&参数!数据库名称.值

此方法唯一的小问题是参数名称在 URI 中可见,因此买者自负。

The way to achieve this could be adding 3 parameters to your report (.rdl) file

ServerName

DatabaseName

and if required

Password

Then change the connection string for the datasource like

="data source=" & Parameters!ServerName.Value & ";initial catalog=" & Parameters!DatabaseName.Value

Only small issue with this approach is the paramnames are visible in the URI so caveat emptor

栀梦 2025-01-03 23:30:06

我找到了解决我的问题的替代方案。我创建了一个(.rdl)报告文件,该文件使用在所有数据库中拥有权限的用户作为该用户提供数据源,以及我在数据库中创建单个过程的数据库,假设管理数据库(用于所有过程对所有人来说都很常见),在该过程中,我执行了其他数据库中存在的过程,如下所示:

set @sSql='Execute '+ @databasename + '.'+ @username + '.'+'GetData'
EXEC (@sSql)

其中用户名和数据库名称存在于表中(对于所有数据库)以及列名sentDate,该列名在之后更新为今天的日期执行该数据库名称的过程,以便执行该过程后,数据源移动到用户名和数据库名之后的下一个。并使订阅在 10 分钟后运行,以便它可以通过每次执行时从不同数据库获取数据来发送所有数据库的报告。

I found an alternative solution to my problem. I created a single (.rdl) Report file which used the user which had a right in all the databases gave the datasource as this user, and the database as in which I made single procedure in a database, suppose admin database(used for all procedure which are common to all), In that procedure I executed the procedure which is present in other databases like this:

set @sSql='Execute '+ @databasename + '.'+ @username + '.'+'GetData'
EXEC (@sSql)

where username and Databasename are present in the table(for all database) and a column name sentDate which is update to todays date after executing the procedure for that databaseName, so that the datasource moves to next after username and databasename after executing the procedure. And made the subscription to run after 10 min, so that it can send the reports of all databases, by getting data form different database in each execution.

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