无法连接到SQL Server数据库 [英] Unable to connect to SQL Server database

查看:105
本文介绍了无法连接到SQL Server数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm creating a web application in mvc 4.0 and I need to enable Membership and Authorization using Asp.netWeb Site Administration Tool but when I clicks the security tab it gives me an error

您选择的数据存储有问题.这可能是造成的 无效的服务器名称或凭据,或不足 允许.这也可能是由于角色管理器功能不 被启用.点击下面的按钮,将页面重定向到 您可以选择一个新的数据存储.以下消息可能有助于 诊断问题:无法连接到SQL Server数据库.

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.

和我的连接字符串在下面给出

and my connection string is given below

 <connectionStrings>
    <add name="MusicStoreEntities"
    connectionString="Data Source=|DataDirectory|MvcMusicStore.sdf"
    providerName="System.Data.SqlClient"/>
  </connectionStrings>

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

I cant find any error in the code so please help me

推荐答案

在您的web.config中设置这些

Set these in your 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 了解更多信息

p.s.在此处

这篇关于无法连接到SQL Server数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆