繁体   English   中英

连接到Visual Studio中的数据库以获取会员资格

[英]connecting to a database in visual studio for membership

我有一个自己创建的网站。 在Appdata文件夹中,我创建了一个数据库(info.mdf)。

我将其连接到SQLEXpress

我已经将网络服务添加到SQL mngmnt studio中的可用用户。 我去了用户映射并添加了我的数据库。 我选择了db_owner,public和aspnet_Membership_FullAccess。 我对本地用户名执行了相同的过程,但是我猜是由于设置数据库的方式,本地用户在实际数据库中的用户下方显示为dbo。

我将web.config更改为:

<?xml version="1.0"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
  <connectionStrings>
    <add name="MembershipConnection" connectionString="Server=machinename\SQLEXPRESS;  Initial Catalog=Info;"
         providerName="System.Data.SqlClient" />
  </connectionStrings>
  <system.web>


    <compilation debug="true" targetFramework="4.0"/>
    <authentication mode="Forms">
      <forms loginUrl="~/Account/Login.aspx" timeout="2880"/>
    </authentication>
    <membership defaultProvider="SqlProvider" userIsOnlineTimeWindow="1720">
      <providers>
        <clear/>
        <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="MembershipConnection" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/"/>
        <add name="SqlProvider"
           type="System.Web.Security.SqlMembershipProvider"
           connectionStringName="MembershipConnection"
           enablePasswordReset="true"
           requiresQuestionAndAnswer="false"
           requiresUniqueEmail="false"
           maxInvalidPasswordAttempts="10"
           passwordAttemptWindow="30"
           minRequiredPasswordLength="3"
           minRequiredNonalphanumericCharacters="0"
           applicationName="/" />

      </providers>
    </membership>
    <roleManager enabled ="true" />

  </system.web>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>
</configuration>

我还尝试了连接字符串中的Trusted_Connection = Yes以及Integrated Security = SSPI

我得到的错误是:

[SqlException(0x80131904):无法打开登录请求的数据库“信息”。 登录失败。 用户“ MachineName \\用户名”的登录失败。]

有想法吗?

http://msdn.microsoft.com/en-us/library/ff647396.aspx

该链接说,为了进行Windows身份验证,您必须具有

Trusted_Connection=Yes

要么

Integrated Security=SSPI

在连接字符串中。 希望这可以帮助!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM