views:

66

answers:

1

Hello everyone,

I am using SQL Server 2008 Enterprise with VSTS 2008, and I am developing a simple web application using ASP.Net and Forms Authentication.

When I am using the configuration tool/menu of VSTS of my ASP.Net project (I want to use this tool to manually add some Forms authentication users), I met with the following error (SqlException),

Trying to attach file D:\Projects\MyTest\App_Data\aspnetdb.mdf to automatically named database failed. It may be caused by existing the same name database, or may be caused by specified file can not be opened or caused by the specified file exists in UNC share.

In my computer, there is no aspnetdb.mdf under dir D:\Projects\MyTest\App_Data, and why this dir will be searched? And I have used aspnet_regsql to generate database successfully before I run the configuration tool. Why there is such error? How to fix it?

thanks in advance, George

+2  A: 

Have you set up your provider with a named connection?

<connectionStrings>
  <add name="NamedConnectionString" 
   connectionString="xxxxxxxx" />
</connectionStrings>

 <membership defaultProvider="MembershipADProvider">
  <providers>
    <add
  name="MembershipADProvider"
  type="System.Web.Security.ActiveDirectoryMembershipProvider, System.Web, 
        Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
            connectionStringName="NamedConnectionString" />
   </providers>
 </membership>

You said that you used aspnet_regsql, which suggests that you are attempting to use the ASP.NET Membership Providers. If you don't configure the providers and connections in your config, then it will look for a SQL Server Express file called aspnetdb.mdf in the App_Data directory of your site.

Daniel Dyson
Add named connection is for what purpose and why it is related to my question?
George2
See edited response
Daniel Dyson
Look at http://msdn.microsoft.com/en-us/library/ff648345.aspx
Daniel Dyson
Thanks! I am using AspnetMembershipProvider as default provider, shall I use SqlProvider in order to fix my issue?
George2
Oh yes. Sorry, I copied the ActiveDirectoryMembershipProvider config into my answer by mistake. Yes, use the SQlMembershipProvider sample from the link that I sent you. I'll update my answer shortly. Also, if you are thinking about adding personalised profile information, have a read of this article... http://weblogs.asp.net/scottgu/archive/2006/01/10/435038.aspx
Daniel Dyson
Final question, what is the differences between AspnetMembershipProvider and SQlMembershipProvider?
George2
I suggest you work your wy through the tutorials on this page: http://www.asp.net/security/tutorials
Daniel Dyson
Thanks, question answered!
George2