From: yfat on
Hi,
I want to connect to several databases, is it possible to pass the
connection string as a parameter and change connection to the database
dynamically ?

Thanks.
From: Wayne Snyder on
Try this

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


Of course you can change anything in the connection string... In your case,
you'd provide the catalog instead of the servername...
--
Wayne Snyder MCDBA, SQL Server MVP
Mariner, Charlotte, NC

I support the Professional Association for SQL Server ( PASS) and it''s
community of SQL Professionals.


"yfat" wrote:

> Hi,
> I want to connect to several databases, is it possible to pass the
> connection string as a parameter and change connection to the database
> dynamically ?
>
> Thanks.
From: Mike Collins on
I believe you want the SetDataSourceContents method. You can find an
explanation of it in BOL.

"yfat" wrote:

> Hi,
> I want to connect to several databases, is it possible to pass the
> connection string as a parameter and change connection to the database
> dynamically ?
>
> Thanks.
From: yfat on
Ok, I tried to create a dynamic data source with two parameters - the server
name and the database name like this :

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

but when I try to continue with that data source i get this error about
trying to connect the data base :
"A connection cannot be made to the database. Set and check the connection
string."

sice the connection is a dynamic one, I cannot know at the design time the
user and the password for the data base.

"Wayne Snyder" wrote:

> Try this
>
> ="data source=" &Parameters!ServerName.Value & ";initial
> catalog=AdventureWorks
>
>
> Of course you can change anything in the connection string... In your case,
> you'd provide the catalog instead of the servername...
> --
> Wayne Snyder MCDBA, SQL Server MVP
> Mariner, Charlotte, NC
>
> I support the Professional Association for SQL Server ( PASS) and it''s
> community of SQL Professionals.
>
>
> "yfat" wrote:
>
> > Hi,
> > I want to connect to several databases, is it possible to pass the
> > connection string as a parameter and change connection to the database
> > dynamically ?
> >
> > Thanks.
From: yfat on
I just saw that the connection string on Reporting Services version 1.0
cannot be based on expressions, Is it possible on the next version ?

"yfat" wrote:

> Ok, I tried to create a dynamic data source with two parameters - the server
> name and the database name like this :
>
> ="data source=" &Parameters!ServerName.Value & ";initial
> catalog=" &Parameters!DBName.Value
>
> but when I try to continue with that data source i get this error about
> trying to connect the data base :
> "A connection cannot be made to the database. Set and check the connection
> string."
>
> sice the connection is a dynamic one, I cannot know at the design time the
> user and the password for the data base.
>
> "Wayne Snyder" wrote:
>
> > Try this
> >
> > ="data source=" &Parameters!ServerName.Value & ";initial
> > catalog=AdventureWorks
> >
> >
> > Of course you can change anything in the connection string... In your case,
> > you'd provide the catalog instead of the servername...
> > --
> > Wayne Snyder MCDBA, SQL Server MVP
> > Mariner, Charlotte, NC
> >
> > I support the Professional Association for SQL Server ( PASS) and it''s
> > community of SQL Professionals.
> >
> >
> > "yfat" wrote:
> >
> > > Hi,
> > > I want to connect to several databases, is it possible to pass the
> > > connection string as a parameter and change connection to the database
> > > dynamically ?
> > >
> > > Thanks.