【发布时间】:2013-01-15 09:08:23
【问题描述】:
我遇到了一个最奇怪的问题:当我编写一个新站点时,一切都运行良好,而我正在工作的一个晚上突然站点无法再连接到 SQL Server。我可以使用 SQL Server Management Studio 愉快地连接,但该站点抛出以下异常。
此机器上的防火墙已完全禁用。
一个问题是我有一个在我创建的本地用户下运行的 SQL Server。有时当我重新启动 SQL Server 服务以查看是否可以解决问题时,该服务会抱怨登录失败。然后,我重新输入最初使服务运行的相同凭据,然后在再次说明该帐户已被授予登录作为服务权限后启动。但是,我尝试使用 NETWORK SERVICES 和 LOCAL SYSTEM,这两种方法都会从我的站点提示相同的异常。
不过,有时它确实有效。我在连接域的笔记本上运行它,所以我想知道这是否与我在家时无法与域交谈有关。然而,我创建的服务帐户是本地帐户。
我在 Windows 8 Enterprise 上的 IIS Express 上运行它(以防万一它是 Win8 的一些已知问题)。
将Pooling=no 添加到连接字符串也没有效果。 [Ref]
这是我的连接字符串:Data Source=.;Initial Catalog=NotesBoard;Integrated Security=SSPI;
我还在“。”上使用了我的机器名称。以同样的结果。甚至尝试过 FQDN。
System.Web.HttpException 未被用户代码处理
HResult=-2147467259 消息=无法连接到 SQL Server 数据库。源=System.Web 错误代码=-2147467259 WebEventCode=0 堆栈跟踪: 在 System.Web.DataAccess.SqlConnectionHelper.CreateMdfFile(字符串 fullFileName,字符串数据目录,字符串连接字符串) 在 System.Web.DataAccess.SqlConnectionHelper.EnsureDBFile(字符串 连接字符串) 在 System.Web.DataAccess.SqlConnectionHelper.GetConnection(字符串 连接字符串,布尔恢复模拟) 在 System.Web.Security.SqlRoleProvider.GetRolesForUser(字符串用户名) 在 WebMatrix.WebData.SimpleRoleProvider.GetRolesForUser(字符串用户名) 在 System.Web.Security.RolePrincipal.IsInRole(字符串角色) 在 d:\dtaylor\Documents\Visual Studio 中的 ASP._Page_Views_Shared__Layout_cshtml.Execute() 2012\Projects\NotesBoard\NotesBoard\Views\Shared_Layout.cshtml:line 28 在 System.Web.WebPages.WebPageBase.ExecutePageHierarchy() 在 System.Web.Mvc.WebViewPage.ExecutePageHierarchy() 在 System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) 在 System.Web.WebPages.WebPageBase.c__DisplayClass7.b__6(TextWriter 作家) 在 System.Web.WebPages.HelperResult.WriteTo(TextWriter 作家) 在 System.Web.WebPages.WebPageBase.Write(HelperResult 结果) 在 System.Web.WebPages.WebPageBase.RenderSurrounding(字符串 partialViewName,Action1 body) at System.Web.WebPages.WebPageBase.PopContext() at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) at System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance) at System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer) at System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) at System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult) at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass1a.<InvokeActionResultWithFilters>b__17() at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func1 继续)
内部异常:System.Web.HttpException H结果=-2147467259 消息=无法连接到 SQL Server 数据库。 来源=System.Web 错误代码=-2147467259 WebEventCode=0 堆栈跟踪: 在 System.Web.Management.SqlServices.GetSqlConnection(字符串服务器, 字符串用户、字符串密码、布尔值信任、字符串 连接字符串) 在 System.Web.Management.SqlServices.SetupApplicationServices(字符串 服务器,字符串用户,字符串密码,布尔值信任,字符串 连接字符串、字符串数据库、字符串 dbFileName、SqlFeatures 功能,布尔安装) 在 System.Web.Management.SqlServices.Install(字符串数据库,字符串 dbFileName,字符串连接字符串) 在 System.Web.DataAccess.SqlConnectionHelper.CreateMdfFile(字符串 fullFileName,字符串数据目录,字符串连接字符串) 内部异常:System.Data.SqlClient.SqlException H结果=-2146232060 消息=建立与 SQL Server 的连接时发生与网络相关或特定于实例的错误。服务器是 未找到或无法访问。验证实例名称是否为 正确,并且 SQL Server 配置为允许远程连接。 (提供者:SQL 网络接口,错误:26 - 错误定位 服务器/实例指定) Source=.Net SqlClient 数据提供者 错误代码=-2146232060 班级=20 行号=0 数字=-1 服务器="" 状态=0 堆栈跟踪: 在 System.Data.SqlClient.SqlInternalConnection.OnError(SqlException 异常,布尔 breakConnection,Action1 wrapCloseInAction) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) at System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, Boolean withFailover) at System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, Boolean withFailover) at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString connectionOptions, SqlCredential credential, TimeoutTimer timeout) at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance) at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions) at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions) at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup, DbConnectionOptions userOptions) at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource1 重试,DbConnectionOptions userOptions,DbConnectionInternal& 连接) 在 System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection 外部连接,DbConnectionFactory 连接工厂, 任务完成源1 retry, DbConnectionOptions userOptions) at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource1 重试) 在 System.Data.SqlClient.SqlConnection.Open() 在 System.Web.Management.SqlServices.GetSqlConnection(字符串服务器, 字符串用户、字符串密码、布尔值信任、字符串 连接字符串) 内部异常:
更新: 这个错误在新帖子here中更清楚地定义了
【问题讨论】:
标签: sql-server-2008 asp.net-mvc-4