Welcome to TechNet Blogs Sign in | Join | Help

Connecting to multiple Data Sources using single Report

I have been looking for something like this for ages. This could be very useful to run a common report on a multiple servers. 

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

Data Source Expressions:
You can put an expression into a connection string to allow users to select the data source at run time. For example, suppose a multinational firm has data servers in several countries. With an expression-based connection string, a user who is running a sales report can select a data source for a particular country before running the report.

The following example illustrates the use of a data source expression in a SQL Server connection string. The example assumes you have created a report parameter named ServerName, and DatabaseName:

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

See attached picture.

Data source expressions are processed at run time or when a report is previewed. The expression must be written in Visual Basic. Use the following guidelines when defining a data source expression:

  • Design the report using a static connection string. A static connection string refers to a connection string that is not set through an expression (for example, when you follow the steps for creating a report-specific or shared data source, you are defining a static connection string). Using a static connection string allows you to connect to the data source in Report Designer so that you can get the query results you need to create the report.
  • When defining the data source connection, do not use a shared data source. You cannot use a data source expression in a shared data source. You must define a report-specific data source for the report.
  • Specify credentials separately from the connection string. You can use stored credentials, prompted credentials, or integrated security.
  • Add a report parameter to specify a data source. For parameter values, you can either provide a static list of available values (in this case, the available values should be data sources you can use with the report) or define a query that retrieves a list of data sources at run time.
  • Be sure that the list of data sources shares the same database schema. All report design begins with schema information. If there is a mismatch between the schema used to define the report and the actual schema used by the report at run time, the report might not run.
  • Before publishing the report, replace the static connection string with an expression. Wait until you are finished designing the report before you replace the static connection string with an expression. Once you use an expression, you cannot execute the query in Report Designer. Furthermore, the field list in the Datasets window and the Parameters list will not update automatically.

 

Published Tuesday, June 26, 2007 1:31 PM by vishah
Filed under:

Attachment(s): RSConString.jpg

Comments

Anonymous comments are disabled
 
Page view tracker