all groups > sql server reporting services > may 2006 >
You're in the

sql server reporting services

group:

how to change database at runtime?


Re: how to change database at runtime? Bruce L-C [MVP]
5/17/2006 2:47:47 PM
sql server reporting services:
In 2005 you will be able to have dynamic datasources. From 2005 help:

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:

Copy Code

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




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:

[quoted text, click to view]

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 share 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.

[quoted text, click to view]

--
Bruce Loehle-Conger
MVP SQL Server Reporting Services

[quoted text, click to view]

how to change database at runtime? Lori
5/17/2006 6:36:58 PM
Hello,

Our customers often have 2 or more databases with the same structure.
How can we pass the database as a parameter at runtime in Reporting Services
2005?

Thank you,

Loreaca

Re: how to change database at runtime? Lori
5/18/2006 12:00:00 AM
Perfect.
Thank you!


[quoted text, click to view]

AddThis Social Bookmark Button