changing catalog name at runtime using selfservicing

Posts   
 
    
Ioish
User
Posts: 16
Joined: 01-Aug-2007
# Posted on: 02-Jan-2008 19:00:01   

One of our applications has to be able to switch, at runtime, to another database. I'm aware of the fact that the Adapter style is the best choice for this, but unfortunately the application has already been build using the selfservicing style. Rewriting the whole thing would take too much time (I guess)

Besides the hints and instructions on changing the .config file, I didn't find any information on how to do this at runtime with selfservicing classes. Is it actually possible?

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 03-Jan-2008 04:16:10   

Hi Ioish, that's possible. Please read: LLBLGenPro Help - Using generated code - SelfServicing - DbUtils functionality.

David Elizondo | LLBLGen Support Team
Ioish
User
Posts: 16
Joined: 01-Aug-2007
# Posted on: 03-Jan-2008 18:24:37   

Hi Daelmo,

I tried that and verified with the debugger that that property of dbutils gets set to the correct connectionstring, but it still connects to the catalog that was used for generating the code. I'm not using catalog overwriting in the .config file btw. Any idea of what might be going wrong?

I'm using version 2.0.50727 of the runtime libraries and used 2.5 Final to generate the code.

Thanks!

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 04-Jan-2008 10:29:59   

I assume you want to switch between catalogs with different catalog names, being in the same server or not. For this you should use Catalog Name Overwriting in the config file, and use an empty string for the new catalog name part, this way the catalog name supplied in the connection string will be used instead of the one generated in code.

Ioish
User
Posts: 16
Joined: 01-Aug-2007
# Posted on: 04-Jan-2008 14:07:12   

That's correct, in this case I want to be able to switch to a different catalog, although it has to be done at runtime. I'm familiar with Catalog Name Overwriting, but it doesn't seem possible to do this at runtime. Is there a way to control this mechanism in code instead of changing the config file each time the app has to switch catalogs?

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 04-Jan-2008 15:31:36   

I think you have mis-understood me.

You have to use CatalogName Overwriting once, to set the New catalog name to an empty string.

This will force the application to use the Catalog Name supplied at runtime in the connection string.

So at runtime you can alter the catalog name by providing different connection strings, as you have done before.

Ioish
User
Posts: 16
Joined: 01-Aug-2007
# Posted on: 04-Jan-2008 16:26:02   

Ok, I didn't know it had that effect. It's working fine now, thanks!