Is there a way for me to dynamically specify the connection string at run time?

Posts   
 
    
PaulUk
User
Posts: 3
Joined: 16-Nov-2009
# Posted on: 16-Nov-2009 15:47:09   

Is there a way for me to dynamically specify the connection string at run time? i.e. i have two identical dbs and i need to call data from db "a" or db "b" depending on the logged in user.

Is this possible?

Thanks Paul

Walaa avatar
Walaa
Support Team
Posts: 14983
Joined: 21-Aug-2005
# Posted on: 16-Nov-2009 16:31:25   

You should use the Adapter template set.

And at runtime you can set the ConnectionString property of each DataAccessAdapter object you use, this will be used instead of the one in the config file.

Also if both of these database reside in the same database instance, but with different catalog names.

Then you will need to use a sqlServerCatalogNameOverwrites section in your application config file, and set the new catalog name to an empty string "".

This way the catalogName passed in the connectionString will be the one to use.