我似乎无法通过网站管理工具创建aspnetdb.mdf。 我正在使用SQL Express 2008和Visual Studio Web Developer 2010 Express。 我在管理工具中收到以下错误:
您选择的数据存储存在问题。这可能是造成的 由无效的服务器名称或凭据,或由不足 允许。它也可能是由角色管理器功能引起的 被启用。单击下面的按钮可重定向到其中的页面 您可以选择新的数据存储。
以下消息可能有助于诊断问题:错误 在执行SQL文件'InstallCommon.sql'期间发生。该 SQL错误号是5170,SqlException消息是:不能 创建文件'C:\ USERS ** \ DOCUMENTS \ VISUAL STUDIO 2010 \ WEBSITES \ BUGZ-B-GONE \ APP_DATA \ ASPNETDB_TMP.MDF'因为它 已经存在。更改文件路径或文件名,然后重试 操作。 CREATE DATABASE失败。列出的某些文件名不能 创建。检查相关错误。创造 ASPNETDB_97c73957a1fb4a189ccca0449aa7d754数据库......
删除mdf文件或更改路径时,我也会收到此错误。
下面是web.config文件:
<configuration>
<connectionStrings>
<add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient"/>
<add name="DATABASEConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\DATABASE.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient"/>
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
</assemblies>
</compilation>
<authentication mode="Forms">
<forms loginUrl="~/Account/Login.aspx" timeout="2880"/>
</authentication>
<membership>
<providers>
<clear/>
<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/"/>
</providers>
</membership>
<profile>
<providers>
<clear/>
<add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/"/>
</providers>
</profile>
<roleManager enabled="true">
<providers>
<clear />
<add connectionStringName="ApplicationServices" applicationName="/"
name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" />
<add applicationName="/" name="AspNetWindowsTokenRoleProvider"
type="System.Web.Security.WindowsTokenRoleProvider" />
</providers>
</roleManager>
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
答案 0 :(得分:0)
您的错误表明数据库已存在,因此请先删除它,然后再运行WSAT。如果不起作用,则删除web.config并将新的配置文件添加到项目中,然后运行WSAT并添加aspnetdb数据库。
您也可以尝试aspnet_regsql
路径:C:\ Windows \ Microsoft.NET \ Framework \ v4.0.30319
运行它,然后您可以从数据库中添加或删除AspNet数据库表。 阅读MSDN
的更多详情