简体   繁体   English

SSRS报告切换数据源

[英]SSRS Report Switch Datasource

I am using SSRS reports and now I want to change data-source base on parameter. 我正在使用SSRS报告,现在我想根据参数更改数据源。 I had all ready tried to create a dynamic data source base on parameter and it works perfect on our local environment. 我已经准备好尝试根据参数创建一个动态数据源,并且它在我们的本地环境中运行良好。 But on production we are not able connect database due to security issue. 但是由于安全问题,在生产中我们无法连接数据库。

To overcome the security issue. 克服安全问题。 we had created two data source "ProdDB" and "ArchDB" in reporting server and map with my report's data source 我们在报表服务器中创建了两个数据源“ ProdDB”和“ ArchDB”,并映射了我报表的数据源

Now I want to know how we can Switch data source base on parameter like Report parameter @dbsource = "Prod" 现在,我想知道如何基于诸如Report parameter @dbsource =“ Prod”之类的参数切换数据源

if @dbsource.value = "Prod" then 
  datasource = "ProdDB
Else 
  DataSource = "ArchDB"

Here is what you can do 这是你可以做的

  1. Create two report parameters as databaseName and DatabaseServer 创建两个报表参数,分别为databaseName和DatabaseServer

在此处输入图片说明

  1. in datasource-> properties -> connection String -> expression write a connection string as below 在数据源->属性->连接字符串->表达式中,如下所示编写连接字符串

="Data Source=" + Parameters!databaseServer.Value + ";Initial Catalog=" + Parameters!databaseName.Value

This will ask database name and database server as a report parameters, if you are running the report as data driven subscriptions you can pass these parameters dynamically from a query or static subscription parameters. 这将询问数据库名称和数据库服务器作为报告参数,如果您将报告作为数据驱动的订阅运行,则可以从查询或静态订阅参数动态传递这些参数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM