Catalog Overwriting during Runtime?

Posts   
 
    
HaulMark
User
Posts: 24
Joined: 11-Aug-2004
# Posted on: 12-Apr-2008 04:38:16   

I have a user requirement to allow Catalogs to be renamed but I'm not sure how to program this. I have read that the app.config file cannot be modified easily at runtime so is there another way to overwrite the LLBL Catalog name with the user defined name without modifying the app.config?

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 12-Apr-2008 05:48:22   

Are you using Adapter or SelfServicing? What database are you using?

For SelfServicing: LLBLGenPro Help - Using the generated code - SelfServicing - DbUtils functionality

For Adapter: LLBLGenPro Help - Using the generated code - Adapter - DataAccessAdapter functionality - Functionality - Catalog specific persistence info

David Elizondo | LLBLGen Support Team
HaulMark
User
Posts: 24
Joined: 11-Aug-2004
# Posted on: 13-Apr-2008 05:21:55   

daelmo,

Thanks for the quick reply.

So if my LLBL was generated against a CATALOG called "DATABASE1" and the user installs the product and renames the CATALOG to "MYDATABASE", I can use the DBUtils.ActualConnectionstring to use the "MYDATABASE" and it will automatically overwrite the Catalog name similiar to "Catalog name overwriting" in "Generated code - Application configuration through .config files"?

HaulMark
User
Posts: 24
Joined: 11-Aug-2004
# Posted on: 13-Apr-2008 05:32:53   

daelmo,

I tried using the DBUtils and it does not work as LLBL is still looking for the original Catalog Name. I guess I did not work my initial question properly - let me try again: Is there a way to overwrite the Catalog Name programatically instead of doing it in the app config. My customer requires the ability for them to change the DB name...

Thanks!

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 13-Apr-2008 21:38:10   

Hi HaulMark,

Ok. Here is what you should to do:

  1. Configure Catalog name overwriting at config file, staying "" for the new catalog name. This says that the catalog name included at connectionString should be used.
<configSections>
    <section name="sqlServerCatalogNameOverwrites" type="System.Configuration.NameValueSectionHandler" />
</configSections>

<sqlServerCatalogNameOverwrites>
    <add key="OldNameCatalog" value="" />
</sqlServerCatalogNameOverwrites>
  1. Modify the DBUtils.ActualConnectionString (including the new catalog name) where appropriate somewhere in your code.
DbUtils.ActualConnectionString = "....initial catalog=NewCatalog;....";

Please let me know if you made it.

David Elizondo | LLBLGen Support Team
rboarman
User
Posts: 83
Joined: 01-Feb-2005
# Posted on: 07-May-2009 20:31:08   

What version was this functionality introduced in? My company is still using 2.0.

The above fix is not working for me.

Thanks,

Rick

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 08-May-2009 07:32:55   

Hi Rick,

If you refer to the Catalog Name Overwriting functionality, AFAIK, this was introduced in v2.0. I quote the v2.0 manual ("Migrating your code" section):

All persistence info now contains the catalog name as it is known in the project (if applicable, like with SqlServer). This is a change from v1.0.200x.y where the catalog name was only generated into the persistence info when 2 or more catalogs were in the project. Because the catalog name is in the persistence info, you can't simply switch catalogs by setting a connection string, if you need to connect to a different catalog at runtime then the one you used to create the project. To be able to do so, you need catalog name overwriting through the config file. Please see Generated code - Application configuration through .config files for more details on this.

So, if you are experimenting problems with this please open a new thread (to maintain order in the old threads) and provide the appropriate info (http://llblgen.com/tinyforum/Messages.aspx?ThreadID=7722) wink

David Elizondo | LLBLGen Support Team