Can't change Catalog name at runtime

Posts   
 
    
happyfirst
User
Posts: 215
Joined: 28-Nov-2008
# Posted on: 28-Jan-2009 21:46:18   

Ver 2.6, sql server 2008, self servicing, console application

I've created some objects from a template db. Now I'm trying to connect to them in a test db. It seems I can change everything except the Initial Catalog via DBUtils.ActualConnectionString. I've searched this forum and it seems others have the same problem. I do NOT want a config file fix (even though I tried them and they didn't work). I want a fix that works from C# CODE.

So how do I change the catalog name at runtime from code? Why can't you just take my connection string AS IS instead of parsing it?

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 29-Jan-2009 10:22:11   

One can have entities from more than one catalog in the same project, that's why the Catalog Name is hard coded.

If you use Catalog name overwriting in the config file and set the new catalog name to empty string, the one in the connection string shall be used.

Otherwise you should be using the Adapter model rather than SelfServicing. Where you can use the following DataAccessAdaoter CTor to specify a CatalogNameToUse.

public DataAccessAdapter(string connectionString, bool keepConnectionOpen, CatalogNameUsage catalogNameUsageSetting, string catalogNameToUse) 
happyfirst
User
Posts: 215
Joined: 28-Nov-2008
# Posted on: 29-Jan-2009 13:49:02   

Since it seems there is a way to replace the hardcoded catalog name for self-servicing at runtime from within the actual connection string, I don't understand why it can't just work as one would expect. Why the extra step for a config file to empty it out first????

But if that should work, then I'll give it another shot. I tried some settings I found in another post but they didn't work. How should the app.config look for a console application to clear out the name?

MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 29-Jan-2009 20:48:24   

Something like...

<sqlServerCatalogNameOverwrites>
    <add key="OldNameCatalog1" value="" />
</sqlServerCatalogNameOverwrites>

Matt