[英]connecting to a database in visual studio for membership
I have a website that I created. 我有一个自己创建的网站。 In the Appdata folder I created a database (info.mdf). 在Appdata文件夹中,我创建了一个数据库(info.mdf)。
I connected it to SQLEXpress 我将其连接到SQLEXpress
I have added NETWORK SERVICE to available users in SQL mngmnt studio. 我已经将网络服务添加到SQL mngmnt studio中的可用用户。 I went to user mapping and added my database. 我去了用户映射并添加了我的数据库。 I selected the db_owner, public and aspnet_Membership_FullAccess. 我选择了db_owner,public和aspnet_Membership_FullAccess。 I did the same process with my local username but I guess because of the way I setup my database the local user shows up as dbo under the users in the actual database. 我对本地用户名执行了相同的过程,但是我猜是由于设置数据库的方式,本地用户在实际数据库中的用户下方显示为dbo。
I altered my web.config to say: 我将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>
I also tried Trusted_Connection=Yes in the connection string as well as Integrated Security=SSPI 我还尝试了连接字符串中的Trusted_Connection = Yes以及Integrated Security = SSPI
The error I get is: 我得到的错误是:
[SqlException (0x80131904): Cannot open database "Info" requested by the login. [SqlException(0x80131904):无法打开登录请求的数据库“信息”。 The login failed. 登录失败。 Login failed for user 'MachineName\\username'.] 用户“ MachineName \\用户名”的登录失败。]
Ideas? 有想法吗?
http://msdn.microsoft.com/en-us/library/ff647396.aspx http://msdn.microsoft.com/en-us/library/ff647396.aspx
This link says that in order to do windows authentication, you must have 该链接说,为了进行Windows身份验证,您必须具有
Trusted_Connection=Yes
or 要么
Integrated Security=SSPI
in the connection string. 在连接字符串中。 Hope this helps! 希望这可以帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.