gpt4 book ai didi

asp.net-mvc-4 - 无法连接到 SQL Server 数据库

转载 作者:行者123 更新时间:2023-12-04 11:26:25 25 4
gpt4 key购买 nike

我正在 mvc 4.0 中创建一个 Web 应用程序,我需要使用 Asp.netWeb 站点管理工具启用成员资格和授权,但是当我单击安全选项卡时,它给了我一个错误

There is a problem with your selected data store. This can be caused by an invalid server name or credentials, or by insufficient permission. It can also be caused by the role manager feature not being enabled. Click the button below to be redirected to a page where you can choose a new data store. The following message may help in diagnosing the problem: Unable to connect to SQL Server database.



下面给出了我的连接字符串
 <connectionStrings>
<add name="MusicStoreEntities"
connectionString="Data Source=|DataDirectory|MvcMusicStore.sdf"
providerName="System.Data.SqlClient"/>
</connectionStrings>

我在代码中找不到任何错误,所以请帮助我

最佳答案

在您的 web.config 中设置这些

<membership defaultProvider="SqlMembershipProvider">
<providers>
<add
name="SqlMembershipProvider"
type="System.Web.Security.SqlMembershipProvider"
connectionStringName="MusicStoreEntities"
/>
</providers>
</membership>

角色
<roleManager defaultProvider ="SqlRoleProvider" >
<providers>
<add
name="SqlRoleProvider"
type="System.Web.Security.SqlRoleProvider"
connectionStringName="MusicStoreEntities"
/>
</providers>
</roleManager>

http://msdn.microsoft.com/en-us/library/ms731049.aspx欲了解更多信息

附言从 here 中删除了示例

关于asp.net-mvc-4 - 无法连接到 SQL Server 数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16317850/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com