Problem with connectionstrings

Posts   
 
    
Posts: 42
Joined: 22-Jan-2007
# Posted on: 24-Jan-2007 16:52:23   

I am using JCL framework (2.4) for the BL part. In my application the connectionstrings are being read from the application's Context, so I can change these at runtime. Works fine with my Access dbdriver DAL/BL. But not with my SqlServer DAL/BL; despite the fact that the connectionstrings are changed, internally the database keeps pointing to the old (design) values. Even when I change "Context" to "ConfigFile" in the ConnectionStringOptions in appSettings and change the ConnectionStrings in de app.config to another database, the database keeps pointing to the design one. The Access LLBLGEN project is a conversion from the SqlServer project (done with ProjectConverter). Any idea what could be wrong ?

bclubb
User
Posts: 934
Joined: 12-Feb-2004
# Posted on: 25-Jan-2007 02:08:51   

I would imagine this is happening because the catalog is included in the name of the columns in the project. So if you connect to the same server, but change the database in the connection string you still won't access the other db. To fix this read the section of the manual "Generated code - Application configuration through .config files". The "Catalog name overwriting (SqlServer only)" portion should help you with this problem.

If it doesn't work then just let us know.

Posts: 42
Joined: 22-Jan-2007
# Posted on: 25-Jan-2007 10:47:15   

bclubb wrote:

I would imagine this is happening because the catalog is included in the name of the columns in the project. So if you connect to the same server, but change the database in the connection string you still won't access the other db. To fix this read the section of the manual "Generated code - Application configuration through .config files". The "Catalog name overwriting (SqlServer only)" portion should help you with this problem.

If it doesn't work then just let us know.

Ok, that worked, but now I want to be able to change that setting at runtime. I know this can be done easily for AppSettings and ConnectionStrings section (via System.Configuration.ConfigurationManager), but I cannot find the way to do this for the "sqlServerCatalogNameOverwrites" section.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 25-Jan-2007 10:57:37   

JCL is adapter, right? You can specify which connection string to use when an adapter is instantiated.

Frans Bouma | Lead developer LLBLGen Pro
Posts: 42
Joined: 22-Jan-2007
# Posted on: 25-Jan-2007 15:54:20   

Otis wrote:

JCL is adapter, right? You can specify which connection string to use when an adapter is instantiated.

Yes, I can (and do) specify the connectionstrings to use either via the app.Config ConnectionStrings section or via the JCL.ApplicationContext.ClientContext. But the only way to change the "initial catalog" name seems to be the "sqlServerCatalogNameOverwrites" method.

bclubb
User
Posts: 934
Joined: 12-Feb-2004
# Posted on: 26-Jan-2007 02:02:55   

This is explained in good detail under the section of the manual "Generated code - DataAccessAdapter Functionality, Adapter" then under Catalog specific persistence info (SqlServer specific). If this doesn't do everything you need let us know.

Posts: 42
Joined: 22-Jan-2007
# Posted on: 26-Jan-2007 10:14:13   

bclubb wrote:

This is explained in good detail under the section of the manual "Generated code - DataAccessAdapter Functionality, Adapter" then under Catalog specific persistence info (SqlServer specific). If this doesn't do everything you need let us know.

I have set the "value=" part in the "sqlServerCatalogNameOverwrites" section to an empty string; now I can switch to any other sqlserver database at runtime by changing the catalog name in the connectionstring. My problem is solved, sorry for the inconvenience.

Tomy
User
Posts: 1
Joined: 20-Feb-2007
# Posted on: 20-Feb-2007 08:03:07   

bclubb wrote:

I would imagine this is happening because the catalog is included in the name of the columns in the project. So if you connect to the same server, but change the database in the connection string you still won't access the other db. To fix this read the section of the manual "Generated code - Application configuration through .config files". The "Catalog name overwriting (SqlServer only)" portion should help you with this problem.

If it doesn't work then just let us know.

I have the same problem in changing the catalog in the connection string too. I've tried the "sqlServerCatalogNameOverwrites" method. But I've got a run-time error: "The type initializer for 'SD.LLBLGen.Pro.DQE.SqlServer.DynamicQueryEngine' threw an exception."

Belows are what I've done in app.config: <appSettings> <add key="Main.ConnectionString" value="data source=somedbserver;initial catalog=SIRS_1;User ID=someuser;Password=somepassword;persist security info=false;packet size=4096"/> <add key="SqlServerDQECompatibilityLevel" value="2" /> </appSettings> <configSections> <section name="sqlServerCatalogNameOverwrites" type="System.Configuration.NameValueSectionHandler, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/> </configSections> <sqlServerCatalogNameOverwrites> <add key="SIRS_LLBLGEN" value="SIRS_1" /> </sqlServerCatalogNameOverwrites>

Have I done anything wrong? rage

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 20-Feb-2007 09:06:51   

You have to place the Config Sections specification right below the first element in the config file. Thats a requirement of .net.

Frans Bouma | Lead developer LLBLGen Pro
Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 20-Feb-2007 09:07:22   

Please don't Hijack older/others threads, as stated here: http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=7717

Is this a Web app. or a Windows app.?

<configSections>
     <section name="sqlServerCatalogNameOverwrites" type="System.Configuration.NameValueSectionHandler, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
    </configSections>

Try to have the configSections part in the begining of the config file.