- Home
- LLBLGen Pro
- LLBLGen Pro Runtime Framework
Switching databases
Joined: 27-Mar-2007
Hi, I have two databases, one for development and one for web site access. Both are within the same instance of SQL 2000 and have differing names. I modified the web.config string to point to the site database db2 instead of the development one db1 and found it would not connect. I was forced to revert to db1 to get it to work. On tralling through the generated code in the DBSpecifics code I found this
base.AddElementMapping( "AcivityActionsEntity", "db1", @"dbo", "AcivityActions", 3 );
This appears to hard code the database in the generated code. Is this the case? I'm using the adapter code.
Cheers
Michael
Joined: 27-Mar-2007
Joined: 27-Mar-2007
Hi, Further to the switching of catalogs I have trouble. The DQE engine throws an exception
[System.TypeInitializationException] = {"The type initializer for 'SD.LLBLGen.Pro.DQE.SqlServer.DynamicQueryEngine' threw an exception."}
The inner exception refers to a line in the web.config file.
InnerException = {"Required attribute 'key' not found. (D:\...<path omitted>...\web.config line 30)"}
The config file has this at lines 29-31 within the configuration node.
<sqlServerCatalogNameOverwrites>
<add name="db1" value="db2"></add>
</sqlServerCatalogNameOverwrites>
The configSections node has this definition
<section name="sqlServerCatalogNameOverwrites" type="System.Configuration.NameValueFileSectionHandler, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" restartOnExternalChanges="false"/>
The connection strings have the initial catalog set to db2. The db login defaults to the db2 database. In addition the application settings have
<add key="CatalogNameUsageSetting" value="1"/>
<add key="CatalogNameToUse" value="db2"/>
I am using LLBLGen pro 2.5, VS2005 sp1 and Vista.
Any help would be appreciated.
Regards Michael Mason
<add key="CatalogNameUsageSetting" value="1"/> <add key="CatalogNameToUse" value="db2"/>
Don't use the above lines, this is provided for backwards compatibility, and not recommended to use.
<sqlServerCatalogNameOverwrites> <add name="db1" value="db2"></add> </sqlServerCatalogNameOverwrites>
So did you generate the code against catalog db1? And now you have to run it against catalog db2?
(EDIT) Also, please check that you have referenced in the generated code project the correct ORMSupport classes dll ( the ....NET20.dll one) and the correct SqlServer DQE dll (the ....NET20.dll one, not the CF one).
Joined: 27-Mar-2007
Hi, I've check all the references and they all are Net2.0 ( version 2.5 ). I commented out the two lines you referred to as being obsolete. I still, however, get the same error and debugging the core LLBLGen code, don't have many other options.
Joined: 27-Mar-2007
Hi, Sorry about that. The code is generated against db1(ttCapture) and I am trying to get it to access db2(ttCapture_web).
Here's the config file with server, passwords and usernames removed. And yes there are two connections strings which are identical.
<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
<sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="Everywhere"/>
<section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
<section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
</sectionGroup>
</sectionGroup>
</sectionGroup>
<sectionGroup name="microsoft.web.preview" type="Microsoft.Web.Preview.Configuration.PreviewSectionGroup, Microsoft.Web.Preview">
<section name="search" type="Microsoft.Web.Preview.Configuration.SearchSection, Microsoft.Web.Preview" requirePermission="false" allowDefinition="MachineToApplication"/>
<section name="searchSiteMap" type="Microsoft.Web.Preview.Configuration.SearchSiteMapSection, Microsoft.Web.Preview" requirePermission="false" allowDefinition="MachineToApplication"/>
<section name="diagnostics" type="Microsoft.Web.Preview.Configuration.DiagnosticsSection, Microsoft.Web.Preview" requirePermission="false" allowDefinition="MachineToApplication"/>
</sectionGroup>
<section name="CaptureV4" type="CaptureV4.CaptureV4Section" />
<section name="sqlServerCatalogNameOverwrites" type="System.Configuration.NameValueFileSectionHandler, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" restartOnExternalChanges="false"/>-->
</configSections>
<CaptureV4 defaultConnectionString="CaptureV4.ConnectionString">
<contactForm mailTo="webmaster.capturev4.com"/>
</CaptureV4>
<sqlServerCatalogNameOverwrites>
<add name="ttCaptureV4" value="ttCaptureV4_web"></add>
</sqlServerCatalogNameOverwrites>-->
<appSettings>
<add key="CaptureV4.ConnectionString" value="data source=??;initial catalog=ttCaptureV4;User ID=??;Password=??;persist security info=False;packet size=4096"/>
<!--<add key="CatalogNameUsageSetting" value="1"/>
<add key="CatalogNameToUse" value="ttCaptureV4_web"/>-->
<add key="TicketTimeout" value="30"/>
<add key="TestUserId" value="10749"/>
<!-- ImageStorage data -->
<add key="ImageRootDirectory" value="~/UploadedFiles"/>
<!--<add key="ImageServerUrl" value="http://media.travelmedia.ltd.uk"/>-->
<!-- Test Image Server Url-->
<add key="ImageServerUrl" value="~/UploadedFiles"/>
<add key="CredentialStoreClass" value="CredentialsStore, CaptureV4.Security.DatabaseCredentialStore"/>
</appSettings>
<connectionStrings>
<remove name="CaptureV4.ConnectionString"/>
<add name="CaptureV4.ConnectionString" connectionString="data source=??;initial catalog=ttCaptureV4;User ID=??;Password=??;persist security info=False;packet size=4096"/>
</connectionStrings>
<system.web>
<!--
Set compilation debug="true" to insert debugging
symbols into the compiled page. Because this
affects performance, set this value to true only
during development.
-->
<compilation debug="true">
<assemblies>
<add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.Transactions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Web.Extensions.Design, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="VsWebSite.Interop, Version=8.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
</assemblies>
</compilation>
<pages>
<controls>
<add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add tagPrefix="llblgenpro" namespace="SD.LLBLGen.Pro.ORMSupportClasses" assembly="SD.LLBLGen.Pro.ORMSupportClasses.NET20"/>
<add tagPrefix="ajaxToolkit" namespace="AjaxControlToolkit" assembly="AjaxControlToolkit"/>
</controls>
</pages>
<httpHandlers>
<remove verb="*" path="*.asmx"/>
<add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/>
<add verb="GET,HEAD,POST" path="*.asbx" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/>
<add verb="*" path="*.media" type="System.Web.HttpForbiddenHandler" validate="true"/>
</httpHandlers>
<httpModules>
<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</httpModules>
<!--
The <authentication> section enables configuration
of the security authentication mode used by
ASP.NET to identify an incoming user.
-->
<authentication mode="Forms">
<forms loginUrl="~/Login.aspx"
protection="All"
timeout="10"
name=".ASPXFORMAUTH"
path="/"
requireSSL="false"
slidingExpiration="true"
cookieless="UseDeviceProfile"
enableCrossAppRedirects="false">
<credentials>
</credentials>
</forms>
</authentication>
<authorization>
<deny users="?"/>
</authorization>
<!--
The <customErrors> section enables configuration
of what to do if/when an unhandled error occurs
during the execution of a request. Specifically,
it enables developers to configure html error pages
to be displayed in place of a error stack trace.
<customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
<error statusCode="403" redirect="NoAccess.htm" />
<error statusCode="404" redirect="FileNotFound.htm" />
</customErrors>
-->
<customErrors mode="RemoteOnly" defaultRedirect="~/Error.aspx">
<error statusCode="404" redirect="~/Error.aspx?code=404" />
<error statusCode="408" redirect="~/Error.aspx?code=408" />
<error statusCode="505" redirect="~/Error.aspx?code=505" />
<error statusCode="403" redirect="~/AccessDenied.aspx"/>
</customErrors>
<trace enabled="true" requestLimit="100"/>
<siteMap enabled="true" defaultProvider="AspNetSqlSiteMapProvider">
<providers>
<add name="AspNetSqlSiteMapProvider" type="CaptureV4.CustomProviders.SqlSiteMapProvider" securityTrimmingEnabled="true" connectionStringName="CaptureV4.ConnectionString" sqlCacheDependency="ttCaptureV4_web:SiteMap"/>
</providers>
</siteMap>
<caching>
<sqlCacheDependency enabled="true" pollTime="5000">
<databases>
<add name="ttCaptureV4_web" connectionStringName="CaptureV4.ConnectionString"/>
</databases>
</sqlCacheDependency>
</caching>
</system.web>
<location path="Capture.Master">
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
</location>
</configuration>
<appSettings> <add key="CaptureV4.ConnectionString" value="data source=??;initial catalog=ttCaptureV4;User ID=??;Password=??;persist security info=False;packet size=4096"/> ... </appSettings>
<connectionStrings> <remove name="CaptureV4.ConnectionString"/> <add name="CaptureV4.ConnectionString" connectionString="data source=??;initial catalog=ttCaptureV4;User ID=??;Password=??;persist security info=False;packet size=4096"/> </connectionStrings>
You have the connection string mentioned twice in the config file, that' not needed only one of them is enough. And only one of them is used if both are available (connectionStrings section is checked first) Anyway would you please try and change the catalog in the connection string to ttCaptureV4_web
Joined: 27-Mar-2007
Hi, I found the problem, although a little embarassing. Changing the initial catalog was something I had tried before so I went back and tried it again just to make sure. The same error message came up during debugging. As sometimes happens, I reread the error message and had a brainwave.
<sqlServerCatalogNameOverwrites> <add key="ttCaptureV4" value="ttCaptureV4_web"></add> </sqlServerCatalogNameOverwrites>
I had used **name **instead of key so the engine was quite correct when it said it couldn't find the key attribute.
As Homer Simpson would say slapping his forehead - DOH!
Many thanks for your help.