This is a migrated thread and some comments may be shown as answers.

connection strings in web.config file

1 Answer 126 Views
Design Time (Visual Designer & Tools)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Robert
Top achievements
Rank 2
Robert asked on 16 Sep 2010, 02:09 PM
Hi,

I would like to have openaccess connection strings in web.config file instead of App.config. I have a website and two class library projects:

DataClasses - persistent classes
DataManager - data access code

configs look like this:

web.config:

  
<configuration>
    <configSections>
    <section name="openaccess" type="Telerik.OpenAccess.Config.ConfigSectionHandler,Telerik.OpenAccess.Config, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7ce17eeaf1d59342"/>
    </configSections>
...
 
 <openaccess xmlns="http://www.telerik.com/OpenAccess">
    <connections>
      <connection id="k2shopConnection">
        <connectionString>data source=217.73.17.132;initial catalog=eshop;persist security info=True;user id=sa;password=qwe123+</connectionString>
        <backendconfigurationname>mssqlConfiguration</backendconfigurationname>
      </connection>
      <connection id="DatabaseConnection1">
        <connectionString>Data Source=217.73.17.132;Initial Catalog=eshop;Persist Security Info=True;User ID=sa;Password=qwe123+</connectionString>
        <backendconfigurationname>mssqlConfiguration</backendconfigurationname>
      </connection>
    </connections>
    <references>
      <reference assemblyname="DataManager" configrequired="True" />
      <reference assemblyname="DataClasses" configrequired="True" />
    </references>
  </openaccess>

DataClasses App.config:

<configuration>
  <configSections>
    <section name="openaccess" type="Telerik.OpenAccess.Config.ConfigSectionHandler, Telerik.OpenAccess.Config, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7ce17eeaf1d59342" requirePermission="false" />
  </configSections>
  <openaccess xmlns="http://www.telerik.com/OpenAccess">
    <references />
    <backendconfigurations>
      <backendconfiguration id="mssqlConfiguration" backend="mssql">
        <mappingname>mssqlMapping</mappingname>
        <option.Multithreaded>False</option.Multithreaded>
        <l2CacheEnabled>True</l2CacheEnabled>
      </backendconfiguration>
    </backendconfigurations>
    <mappings current="mssqlMapping">
....
 </mappings>
  </openaccess>
</configuration>

DataManager App.config:

<configuration>
  <configSections>
    <section name="openaccess" type="Telerik.OpenAccess.Config.ConfigSectionHandler, Telerik.OpenAccess.Config, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7ce17eeaf1d59342" requirePermission="false" />
  </configSections>
  <openaccess xmlns="http://www.telerik.com/OpenAccess">
    <references>
      <reference assemblyname="DataClasses" configrequired="True" />
    </references>
    <backendconfigurations>
      <backendconfiguration id="mssqlConfiguration" backend="mssql">
        <mappingname>mssqlMapping</mappingname>
        <option.Multithreaded>False</option.Multithreaded>
        <l2CacheEnabled>True</l2CacheEnabled>
      </backendconfiguration>
    </backendconfigurations>
    <mappings current="mssqlMapping">
      <mapping id="mssqlMapping" />
    </mappings>
  </openaccess>
</configuration>

when I compile I get following error:

Error 143 OpenAccess Error: 
The following problem(s) have occurred :

1. The connection section with id 'DatabaseConnection1' cannot be found in the configuration files traversed from 'C:\Users\Remote\Documents\Visual Studio 2010\Projects\k2shop\k2shop\Projects\k2shop\DataManager\App.config'.

See History property for more details.Verify that a connection section with the same id as the one specified  in the 'ConnectionId' project property exists in the configuration file. DataManager


What am I doing wrong?

Thanks,
Robert

1 Answer, 1 is accepted

Sort by
0
Alexander
Telerik team
answered on 17 Sep 2010, 02:34 PM
Hello Robert,

Please make sure that the UpdateDatabase property is disabled for all projects. This property should be visible in the Properties pane of Visual Studio when a project is selected.
Optionally, you can remove the backendconfigurations and mappings nodes from the DataManager's App.config, as well as the whole openaccess node from the web.config. In order to use a connection string from the web.config, the only thing you should do is to copy it there and make sure it has the correct name. This connection string is treated with higher priority by the runtime than the connection string specified in the App.config files. You can also have a look at the attached project, which demonstrates the correct setup.
Hope that helps.

All the best,
Alexander
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Design Time (Visual Designer & Tools)
Asked by
Robert
Top achievements
Rank 2
Answers by
Alexander
Telerik team
Share this question
or