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.
views:
314answers:
4If you have the right privileges you can can go to http://servername/reports/ and view the data source connection details through there.
If you're using visual studio just look at the data tab.
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.
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.
DataSourceDefinition dataSourceDefinition
= reportingService.GetDataSourceContents("DataSourceName");
string connectionString = dataSourceDefinition.ConnectString;