简体   繁体   English

如何获取报表在SQL Server Reporting Services 2005中使用的数据源

[英]How do you get the DataSource that a report uses in SQL Server Reporting Services 2005

In order to create the proper queries I need to be able to run a query against the same datasource that the report is using. 为了创建正确的查询,我需要能够对报表使用的同一数据源运行查询。 How do I get that information programatically ? 如何以编程方式获取该信息? Preferably the connection string or pieces of data used to build the connection string. 优选地,用于构建连接字符串的连接字符串或数据片段。

DataSourceDefinition dataSourceDefinition 
    = reportingService.GetDataSourceContents("DataSourceName");

string connectionString = dataSourceDefinition.ConnectString;

如果您拥有正确的特权,则可以转到http:// servername / reports /并从中查看数据源连接详细信息。

If you're using visual studio just look at the data tab. 如果您使用的是Visual Studio,则只需查看“数据”标签。

If you just have access to the report on the SSRS server you can navigate to the report, click the Properties tab, then the Data Sources option on the left. 如果您只能访问SSRS服务器上的报告,则可以导航到该报告,单击“属性”选项卡,然后单击左侧的“数据源”选项。

If it's a custom data source you can get the connection info from there. 如果是自定义数据源,则可以从那里获取连接信息。

If it's shared, you'll need to navigate to the data source path shown, and can get the connection info from there. 如果是共享的,则需要导航到显示的数据源路径,并从那里获取连接信息。

EDIT: Also, if you just have the report file itself you should be able to open it in notepad and find the data source information inside. 编辑:此外,如果您只拥有报告文件本身,则应该能够在记事本中打开它并在其中找到数据源信息。 Unless it uses a shared data source I guess... in which case you'll need to find that. 我猜除非它使用共享的数据源,否则您将需要找到它。

EDIT: This answer applied to the question as originally written, before "programmatically" was added. 编辑:此答案适用于最初编写的问题,然后添加“以编程方式”。

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

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