如何解决无法连接到SQL Server数据库? [英] How to solve Unable to connect to SQL Server Database?

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

问题描述

原谅我,如果我的问题是不是有点傻据我是新手到编程。此堆栈在流动的文章<一个href=\"http://stackoverflow.com/questions/20541680/visual-studio-2013-and-asp-net-web-configuration-tool\">Visual工作室2013和ASP.NET Web配置工具救了我天运行在Visual Studio 2013工具WSA但我遇到一个新的问题,它是SQL Server数据库的连接。

Forgive me if my question is stupid or something as far as I am newbie to the programming. This stack over flow article Visual Studio 2013 and ASP.NET Web Configuration Tool saved me days for running the Visual Studio 2013 WSA Tool but I run into a new problem and it is the connection to SQL Server database.

问题是,当我运行IIS防爆preSS通过cmd,然后把地址在浏览器中我重定向到WSA工具,但是当我打的安全选项卡或链接,然后我得到这个错误:

The problem is when I run IIS Express through cmd and then put address in browser I get redirected to WSA Tool but when I hit the security tab or link then I get this error:

有与您选择的数据存储问题。这可以通过一个无效的服务器的名称或凭证,或经许可不足引起的。它也可以通过不使能角色管理器功能而引起的。点击下面的按钮被重定向到一个页面,您可以选择一个新的数据存储。

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:

无法连接到SQL Server数据库

Unable to connect to SQL Server database

我的连接字符串是这样的:

My connection string looks like this:

<connectionStrings>
    <add name="DefaultConnection" 
         connectionString="Data Source=.; Initial Catalog=aspnetdb; User Id=sa; Password=***********; Integrated Security=true" 
         providerName="System.Data.SqlClient" />
</connectionStrings>

和整个我的应用程序的web.config 下面是:

And the whole my application web.config is below:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </configSections>
  <connectionStrings>
    <add name="DefaultConnection" connectionString="Data Source=.; Initial Catalog=aspnetdb; User Id=sa; Password=***********; Integrated Security=true" providerName="System.Data.SqlClient" />
  </connectionStrings>
  <appSettings>
    <add key="webpages:Version" value="2.0.0.0" />
    <add key="webpages:Enabled" value="false" />
    <add key="PreserveLoginUrl" value="true" />
    <add key="ClientValidationEnabled" value="true" />
    <add key="UnobtrusiveJavaScriptEnabled" value="true" />
  </appSettings>
  <system.web>
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5" />
    <authentication mode="Forms">
      <forms loginUrl="~/Account/Login" timeout="2880" />
    </authentication>
    <pages>
      <namespaces>
        <add namespace="System.Web.Helpers" />
        <add namespace="System.Web.Mvc" />
        <add namespace="System.Web.Mvc.Ajax" />
        <add namespace="System.Web.Mvc.Html" />
        <add namespace="System.Web.Optimization" />
        <add namespace="System.Web.Routing" />
        <add namespace="System.Web.WebPages" />
      </namespaces>
    </pages>
  </system.web>
  <system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
  <handlers>
      <remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
      <remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
      <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
      <add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
      <add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />
      <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
    </handlers></system.webServer>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="DotNetOpenAuth.Core" publicKeyToken="2780ccd10d57b246" />
        <bindingRedirect oldVersion="1.0.0.0-4.0.0.0" newVersion="4.1.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="DotNetOpenAuth.AspNet" publicKeyToken="2780ccd10d57b246" />
        <bindingRedirect oldVersion="1.0.0.0-4.0.0.0" newVersion="4.1.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-1.3.0.0" newVersion="1.3.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="v11.0" />
      </parameters>
    </defaultConnectionFactory>
  </entityFramework>
</configuration>

我没有看到&LT; rolemanager启用=真&gt; 在我的MVC应用程序,即使我想其中有过这样的℃的Web应用程序; rolemanager启用=真方式&gt; ,但甚至没有工作

I see no <rolemanager enabled=true>in my MVC Application, even though i tried a web application which have had this <rolemanager enabled="true">but didn't work even.

PS:值得一提的是,当我运行该应用程序它的自我它比罚款多,我可以创建用户,更新用户的密码等......,其结果反射回MS SQL Server数据库的表太多,但不知道什么是魔术在这里。

P.S: Worth to mention that when i run the application it self it works more than fine, i can create users, update users passwords and etc... and the results are reflected back to the MS SQL Server Database tables too but don't know what is the magic here.

你有什么建议?!

问候
Dostdar

Regards Dostdar

推荐答案

如果您打算连接到您的SQL Server作为SA,然后尝试从连接字符串中删除'集成安全性=真正的'。

If you intend to connect to your SQL Server as sa, then try removing 'Integrated Security=true' from your connection string.

当它被设置为true,当前的Windows帐户凭据用于验证。您的Windows用户可能不具有相应权限的数据库。

When it is set to true, the current Windows account credentials are used for authentication. Your Windows user might not have appropriate rights to the DB.

<一个href=\"https://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.connectionstring(v=vs.110).aspx\" rel=\"nofollow\">https://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.connectionstring(v=vs.110).aspx

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

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