The ConnectionString property has not been initialized

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
13 years ago
hi,

I have merged nopCommerce with an existing web application, so I had to merge the web.config files, but I get this error:

The underlying provider failed on Open --> The ConnectionString property has not been initialized

It seems it is not reading the connection string properly. Could you explain exactly where it reads the connectionstring?

Many thanks.

Luca.
13 years ago
Hi Luca,

Did you find a solution to your problem? I seem to be having the same problem and not sure why.

Many thanks

Matt
13 years ago
Hi Matt, no, I'm still waiting for a reply from the nopCommerce Team. Luca.
13 years ago
Connection string is stored in the file ConnectionStrings.config

In web.config file there's reference to connection string specified in ConnectionStrings.config.
13 years ago
yes I know that, this works in the standard installation. but it does not when I moved the .aspx files in a subfolder.
13 years ago
Ok, it doesn't look like anybody else is going to suggest anything so spent some time digging round the source and in my situation it looks as though I'm having problems with the global.asax file which means the NopConfig isn't being initialized, and thus the connection string isn't being picked up.

Not sure if it's the same for you, but worth a try?

Hope you get your issues solved soon.

Matt
13 years ago
thanks Matt, you're a genius, that was the issue. Now it works! Luca.
13 years ago
I've written a membership provider for our sites which uses the Nop database, and packaged it up with various other stuff into a web library for use across our sites. Today I added to the web library a reference to the Nop business logic DLL so I can get access to the CustomerManager and other code that the Nop guys have already written for setting user attributes etc. I'm not sure how I expected it to work without setting a connection string ;) but of course it didn't work.

I've breakpointed the store and indeed the web.config connection block is sent to the business logic DLL at application start.

What I'm wondering if anyone has any ideas for how I can use the business logic DLL in my web library DLL which will be used by a number of sites (3 or more). The best thing I can think of is to copy the config block from the store into the web.config of each site and call NopConfig.Init(); from Application_Start in each site's global.asax, just like NopCommerce does. While I imagine this work (? will test tommorow) does anyone have any better ideas? I'd rather hard code the connection string into one place than have to ensure that all current and future sites have a Nop config block and a global.asax. Something more elegant would be even better.
13 years ago
I still welcome better ideas but the following worked A-ok:

Add to the web.config of the site which references the Business Logic DLL (in this case an indirect reference)

  <configSections>
    <section name="NopConfig" type="NopSolutions.NopCommerce.BusinessLogic.Configuration.NopConfig, Nop.BusinessLogic" requirePermission="false"/>
  </configSections>
  <NopConfig>
    <SqlServer ConnectionStringName="NopSqlConnection"/>
  </NopConfig>

Plus add a connection string called NopSqlConnection.

In global.asax:
<%@ Application Language="C#" %>
<%@ Import Namespace="NopSolutions.NopCommerce.BusinessLogic.Configuration" %>

<script runat="server">
    void Application_Start(object sender, EventArgs e)
    {
    // Code that runs on application startup
    NopConfig.Init();
    }
</script>

Hope that helps someone.
13 years ago
Still doesn't work after following thread above.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.