Problem with connection strings

Posts   
 
    
Ren
User
Posts: 42
Joined: 01-Jul-2005
# Posted on: 14-Jul-2005 02:53:29   

I am trying to place the following in my web.config

<configSections> <section name="sqlServerCatalogNameOverwrites" type="System.Configuration.NameValueSectionHandler" /> </configSections>

<sqlServerCatalogNameOverwrites> <add key="Billingtest" value="Billing" /> <add key="CentralDatatest" value="CentralData" /> </sqlServerCatalogNameOverwrites>

When my code calls the following method....

public static UserPersonEntity GetPersonIdByNetworkId(string networkId) { DataAccessAdapter adapter = new DataAccessAdapter(); UserPersonEntity item = new UserPersonEntity(); item.NetworkId = networkId; adapter.FetchEntity(item);

return item;

}

I get the following error..

An unhandled exception of type 'System.Configuration.ConfigurationException' occurred in system.web.dll (Exception creating section handler)

and the debugger goes here.

protected override IRetrievalQuery CreateSelectDQ(IEntityFields2 fieldsToFetch, IFieldPersistenceInfo[] persistenceInfoObjects, IPredicateExpression filter, long maxNumberOfItemsToReturn, ISortExpression sortClauses, IRelationCollection relationsToWalk, bool allowDuplicates, IGroupByCollection groupByClause, int pageNumber, int pageSize) { return DynamicQueryEngine.CreateSelectDQ(fieldsToFetch.GetAsEntityFieldCoreArray(), persistenceInfoObjects, base.GetActiveConnection(), filter, maxNumberOfItemsToReturn, sortClauses, relationsToWalk, allowDuplicates, groupByClause, pageNumber, pageSize); }

Any help would be appreciated on what I am doing wrong. I woudl assume its something to do with the DataAccessAdapter.

Thanks! Ren

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 14-Jul-2005 09:47:58   

In .NET 1.x, the location of the configSections tag is fixed, you have to place it as the first item in the configuration tag. Is that the case in your web.config file?

Frans Bouma | Lead developer LLBLGen Pro
Ren
User
Posts: 42
Joined: 01-Jul-2005
# Posted on: 14-Jul-2005 19:24:19   

Yes it is. righ above system.web

after system.web I have the catalog name overrights then my appSettings and the closing configuration tag.

This is very strange. The debugger goes right to that line and highlights it in green (CreateSelectDQ) then if I select continue the following message appears.

(Yellow screen of death)

Line 2: <configuration> Line 3: <configSections> Line 4: <section name="sqlServerCatalogNameOverwrites" type="System.Configuration.NameValueSectionHandler" /> Line 5: </configSections> Line 6: <system.web>

Here is my web.config file that i am using: (pound signs are just added to comment out the connection string stuff)

<?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections> <section name="sqlServerCatalogNameOverwrites" type="System.Configuration.NameValueSectionHandler" /> </configSections> <system.web>

<compilation 
     defaultLanguage="c#"
     debug="true"
/>

<customErrors 
mode="RemoteOnly" 
/> 

<authentication mode="Windows" /> 

<authorization>
    <allow users="*" /> 
</authorization>

<trace
    enabled="false"
    requestLimit="10"
    pageOutput="false"
    traceMode="SortByTime"
    localOnly="true"
/>

<sessionState 
        mode="InProc"
        stateConnectionString="tcpip=127.0.0.1:42424"
        sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes"
        cookieless="false" 
        timeout="20" 
/>

<globalization 
        requestEncoding="utf-8" 
        responseEncoding="utf-8" 

/>

</system.web>

<sqlServerCatalogNameOverwrites>
    <add key="Billing" value="Billing" />
    <add key="CentralData" value="CentralData" />
</sqlServerCatalogNameOverwrites>

<!-- application specific settings -->
<appSettings>
<!-- Next set of keys are for general configurations in the web site -->
<add key="runApplicationAsUser" value="" />
<add key="useEncryptedStrings" value="false"/>
<add key="recordsPerPage" value="25"/>
<add key="maxRecordsPerPage" value="100000" />
<add key="maxClaimKeysHeldInViewState" value="700" />
<add key="mailServer" value="" />
<add key="defaultCulture" value="en-US" />
<add key="mainTitle" value="" />
<add key="passToRecoverySystem" value="True" />   
<add key="tabMenuLocation" value="Data/tabs.config" />
<!-- Next set this to 0 for production deployment -->
<add key="debugLevel" value="1" />
<add key="lifeCycleInMinutesGlobalCacheShort" value="60" />
<add key="lifeCycleInMinutesGlobalCacheLong" value="480" />
<!-- Next set of keys are for various messages in the web site -->
<add key="defaultPageErrorMessage" value="Unknown error occurred while displaying the page. If the browser has been idle for over 2 hours you are required to close and re-open the browser." />
<!-- Next set of keys are for specific pages urls in the web site -->
<add key="defaultDesktopPageUrl" value="Default.aspx" />
<add key="defaultDesktopErrorPageUrl" value="/Error/Error.aspx" />
<add key="defaultAccessDeniedPageUrl" value="/AccessDenied.aspx" />
<!-- Next set of keys are for various folder paths in the web site -->
<add key="imagesFolderPath" value="~/Images" />
<add key="sessionTimeout" value="30" />

<!--#########START CONNECTION STRINGS###########--> 
    <add key="ConnString" value="Server=###;Database=Billing;Trusted_Connection=false;user id=##;password=##;"/>
    <add key="CentralDataConnString" value="Server=###;Database=CentralData;Trusted_Connection=false;user id=##;password=##;"/>
<!--#########END CONNECTION STRINGS###########-->

    <add key="billingRoles" value="8,9" />  


<!-- Random sample for Audit section -->
<add key="confidenceNbr" value="6.60" /> <!-- (6.60 for 99% 3.84 for 95% 2.69 for 90%) -->
<add key="confidencePercent" value=".99" /> 
<add key="precisionRate" value=".03" />
<add key="fixedSampleSize" value="10000" />   

</appSettings>

</configuration>

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 15-Jul-2005 10:35:46   

Ok, I tried it here and I ran into the same issue. Googling on it showed me that in ASP.NET you have to specify the complete type etc.

so your section declaration should be:


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

I'll update the docs with this.

Frans Bouma | Lead developer LLBLGen Pro
Ren
User
Posts: 42
Joined: 01-Jul-2005
# Posted on: 15-Jul-2005 18:49:08   

Thank you for your help!

tprohas
User
Posts: 257
Joined: 23-Mar-2004
# Posted on: 19-Jul-2005 21:37:08   

I'm also having a problem related to this. I have two identical databases that I would like to switch between and can't make it work.

I have now tried using the appSettings CatalogNameUsageSetting and CatalogNameToUse and this won't change the database used for a typed view. I then also tried the method using sqlServerCatalogNameOverwrites and this also didn't change the database being used.

When I'm using the sqlServerCatalogNameOverwrites method do I have to have both databases added to the LLBLGen project at catalogs?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 20-Jul-2005 13:15:04   

I answered this in the thread you started about this.

Frans Bouma | Lead developer LLBLGen Pro