Forum


HomeHomePremiumPremiumDevelopmentDevelopmentquerying data from external databasequerying data from external database
Previous
 
Next
New Post
7/24/2015 8:43 AM
 

I'm developing a custom module which will query data from external database not the CMS one so where should I put the connection string in the module project (christoc template) 

I understand that I can manually add the connection to Web.config in the website root but I care about the module when you install it i don't want manual steps

 
New Post
7/24/2015 1:40 PM
 

Johnny,

There is a way to use the .dnn manifest file in the module template to install and uninstall an entry in the DNN web.config such that you don't need a manual step when someone installs your module using the packaging.

<component type="Config">
  <config>
    <configfile>web.config</configfile>
    <install>
      <configuration>
        <nodes>
          <node path="/configuration/appSettings" action="update" key="key" collision="overwrite">
            <add key="MyExternalConnection" value="Data Source=.;Initial Catalog=mydata;User ID=user;Password=abc123;">
          </add></node>
        </nodes>
      </configuration>
    </install>
    <uninstall>
      <configuration>
        <nodes>
          <node path="/configuration/appSettings/add[@key='MyExternalConnection']" action="remove">
        </node></nodes>
      </configuration>
    </uninstall>
  </config>
</component>

Then your module can access the connection string using:

DotNetNuke.Common.Utilities.Config.GetSetting("MyExternalConnection");

Another option is to put the connection string in a resource (.resx) file that gets deployed with your module.

 

Hope either of these suggestions works for you.

Scott

 
New Post
7/24/2015 2:05 PM
 

Sounds good I'll try them, appreciate your help thank you

 
Previous
 
Next
HomeHomePremiumPremiumDevelopmentDevelopmentquerying data from external databasequerying data from external database



Try FREE
30 days money back guaranteed