Welcome to MSDN Blogs Sign in | Join | Help

MarkBerr's Blog

Covering issues related to the ASP.NET features of Membership and RoleManager.

Syndication

Tags

    No tags have been created or used yet.
Default Provider Configuration targets Sql Server Express

In an attempt to solve some of the basic problems with getting the Membership and Roles providers to work out of the box, I'd like to take a minute to talk about their default setup.

The default Membership and Roles providers are Sql based and target a local Sql Server Express (SSE) install.  If your first attempt to load a page which does a Membership or Roles operation results in:

An error has occurred while establishing a connection to the server.  When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Shared Memory Provider, error: 40 - Could not open a connection to SQL Server)

It's likely that SSE is not running.  Maybe you didn't choose to install it during the product install.  You can easily check if it's available (and running) by trying to start the service.  Run the following from a command shell:

net start MSSQL$SQLEXPRESS


Ok, SSE is now running.  Great.  How are the providers configured to target it?

The providers' default configurations point them to use the connection string named "LocalSqlServer" which is defined in the  "machine.config" file which lives in the framework config directory.  In this file, you'll see the following in the connection strings section:

<add name="LocalSqlServer" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true" .../>

This connection string defines a "data source" value that points to a local SSE instance.  From this connection string, you can also see the default database name is going to be "aspnetdb.mdf".  The "|DataDirectory|" notation is special and ADO.NET replaces this value with the the app domain value for the "DataDirectory" variable.  For ASP.NET site's, this value, by default, is "App_Data".  I won't go into the significance of the "User Instance" value in this post since it's a bit beyond what I'm trying to address here.

So that's some basic info around the provider's default configurations and their use of SSE.  Hope this helps at least a few people get the providers running right out of the box which was our goal.

Published Friday, March 31, 2006 11:16 PM by MarkBerr

Comments

# re: Default Provider Configuration targets Sql Server Express @ Wednesday, April 12, 2006 9:34 AM

Hi Mark

On the hosting account I have with Crystaltech, I do not have the use of SQL Server 2005 Express.  Since the site was originally a SQL Serevr 2000 db site, I have used the aspnet_regsql utility to create the ASP.NET membership and role database in my SQL 2000 database, which has worked fine.

I have then amended the connection string to use my application db connection string as show below:

   <membership defaultProvider="CustomizedProvider">
     <providers>
       <add
                 name="CustomizedProvider"
                 type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
                 connectionStringName="hrayConnectionString"
                 enablePasswordRetrieval="true"
                 enablePasswordReset="true"
                 requiresQuestionAndAnswer="false"                  
                 applicationName="/"
                 requiresUniqueEmail="false"
                 passwordFormat="Encrypted"
                 minRequiredNonalphanumericCharacters="0"
               
                 minRequiredPasswordLength="6"                  
                 description="Stores and retrieves membership data from the local SQL Server database file"/>

     </providers>      
   </membership>


However when I attempt to register a test user, the createuserwizard control returns the following error:

"The SSE Provider did not find the database file specified in the connection string. At the configured trust level (below High trust level), the SSE provider can not automatically create the database file. "

But also when I test the same web.config file from my local pc in VWD 2005 the createuserwizard works fine and creates a new user in memebership tables of my application database.

I am not sure btu I suspect from what you say in your blog that this maybe because my hosting company have not installed the SSE for my SQL 2000 database.

Stevo

# re: Default Provider Configuration targets Sql Server Express @ Monday, June 25, 2007 11:45 AM

I changed the connection string of my web.config to point at a remote SQL Server 2005 database but when i deploy my application i cant login using the Login Control and keep getting this error.

The SSE Provider did not find the database file specified in the connection string. At the configured trust level (below High trust level), the SSE provider can not automatically create the database file.

Please help

Tawanda

Tawanda

# re: Default Provider Configuration targets Sql Server Express @ Tuesday, November 13, 2007 8:14 AM

I have the same problem as Tawanda?

Thanx

Anis

Anis75

# re: Default Provider Configuration targets Sql Server Express @ Tuesday, July 15, 2008 4:40 AM

Hi mark

im having a difficulty configuring the database   in the aspnet_regsql utility,

when im about to choose on the database list,

it gives me an error like this:

"Failed to query a list of database names from the SQL server.An error has occurred while establishing a connection to the server.  When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections.(provider: Shared Memory Provider, error: 40 - Could not open a connection to SQL Server)"

what do you think is the problem?

thanks in advance!

dan druff

# MarkBerr s Blog Default Provider Configuration targets Sql Server Express | Quick Diets @ Tuesday, June 09, 2009 11:21 PM

PingBack from http://quickdietsite.info/story.php?id=14674

MarkBerr s Blog Default Provider Configuration targets Sql Server Express | Quick Diets

Anonymous comments are disabled
Page view tracker