This project is read-only.

shopping cart and Manage my profile can't be implemented

Topics: Developer Forum
Jun 18, 2009 at 9:31 AM

When click shopping cart or Manage my profile in the page, both of them can't be implemented, an exception is thrown that is "Unable to connect to SQL Server database", but my database connection is correct and works well.

why?

somebody occurred this issue?

Jun 28, 2009 at 7:39 PM

I would double check your database connection. Out of the box it expects the account you use to have trusted access to the sql server and the sql server be named SQLExpress. Also you must be using SQL Server 2008 and Visual Studio 2008 (Any Edition).

Jun 28, 2009 at 8:59 PM

You need to use SQLExpress 2008.  If you don't want to use SQLExpress you need to mount the MDB youself and update your connection accordingly.  Also you need to use Visual Studio Web Edition for 2008 or greater.

Jul 22, 2009 at 3:13 AM

For the love of Pete! Did anyone ever figure this problem out? My web.config file is fine.... here is the connections string excerpt:

<connectionStrings>
    <add name="TheBeerHouseConnectionString" connectionString="Data Source=.;Initial Catalog=TheBeerHouse;User Id=sa;Password=wishyouknew;" providerName="System.Data.SqlClient"/>
  </connectionStrings>

Just like trendline indicated, the app bombs on the user profile and store links. For example:

 

ShoppingCart shoppingCart = (ShoppingCart)profileBase.GetPropertyValue("ShoppingCart");

 

This is from line 110 in CommerceController.cs. It appears thte the profile provider is trying to connect with a difference connection string than the rest of the application. I'm running Visual Studio 2008 professional with SQL Server 2008 standard. I've attached the database included with the project and updated my web.config as shown above. I'm must stumped. Any advice would be greatly appreciated.

 

 - Matt

Jul 22, 2009 at 1:00 PM

Matt,

Yes we use the profile and membership provider in this application. You must ensure that they are functional as well! Without them anything that uses profiles will not function at all. I believe for this project we tied it directly into the beerhouse database so you can just move the connection string to there. Sorry if there are 2 connection strings, that is just the way Microsoft built the membership provider. Hope this helps.

Jul 22, 2009 at 3:31 PM

Thank you for your reply. Great job on the application, by the way. The more I get into it, the more excited I am to leverage it for my project.

I figured that it was using a differecnt connection string for the membership and profile provider but I cannot find that connection string anywhere in the project itself. I even went to the ASP.Net configuration through VS 2008 to find it but didn't see it there either.

Any ideas on where I may find this?

Thanks again.

 - matt

Jul 22, 2009 at 8:31 PM

I got it working... Here's what I had to do:

  <connectionStrings>
    <remove name="LocalSqlServer"/>
    <add name="LocalSqlServer" connectionString="Data Source=.;Initial Catalog=TheBeerHouse;User Id=sa;Password=youdliketoknow;" providerName="System.Data.SqlClient"/>
    <add name="TheBeerHouseConnectionString" connectionString="Data Source=.;Initial Catalog=TheBeerHouse;User Id=sa;Password=youdliketoknow;" providerName="System.Data.SqlClient"/>
  </connectionStrings>

Strange, because the connectionString clearly points to TheBeerHouseConnectionString:

    <membership>
      <providers>
        <clear/>
        <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="TheBeerHouseConnectionString" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" applicationName="TheBeerHouse" requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="5" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" passwordStrengthRegularExpression=""/>
      </providers>
    </membership>

I found information on this topic here for those who are having the same problem:

http://www.odetocode.com/Articles/427.aspx

Later!

 - Matt

 

Jul 23, 2009 at 4:16 AM

Matt:

Really strange, you mean add
    <remove name="LocalSqlServer"/>
    <add name="LocalSqlServer" connectionString="Data Source=.;Initial Catalog=TheBeerHouse;User Id=sa;Password=youdliketoknow;" providerName="System.Data.SqlClient"/>
before
     <add name="TheBeerHouseConnectionString" connectionString="Data Source=.;Initial Catalog=TheBeerHouse;User Id=sa;Password=youdliketoknow;" providerName="System.Data.SqlClient"/>

?

Jul 24, 2009 at 1:41 AM

Glad that you found the answer on your own. Yeah you do need two seperate connection strings unfortunately but once you have that sorted out it should work perfectly.

May 27, 2014 at 9:17 AM
perfect solution!