【问题标题】:asp.net webforms app trying to connect to database that isn't being referenced anywhere in code?asp.net webforms 应用程序试图连接到代码中任何地方都没有引用的数据库?
【发布时间】:2012-06-27 09:33:01
【问题描述】:

我的服务器上有一些旧数据库,因此将旧的、未使用的数据库脱机。

这导致了一个非常奇怪的问题,因为我的网站抱怨无法连接到这些数据库之一。

我已经在整个代码库中搜索了数据库名称以及服务器上的所有配置文件,但没有一个引用此数据库名称,但是如果我离线,我会收到错误消息?

我无法从错误中看到实际发出连接请求的原因,除了它看起来与 SQL 会话服务器有关。

[SqlException (0x80131904): 数据库 'MyOldDatabaseName' 不能 因离线而打开。]
System.Data.SqlClient.SqlConnection.OnError(SqlException 异常, 布尔中断连接)+1953274
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException 异常,布尔型 breakConnection) +4849707
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +194 System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior、SqlCommand cmdHandler、SqlDataReader 数据流、 BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +2392
System.Data.SqlClient.SqlDataReader.ConsumeMetaData() +33
System.Data.SqlClient.SqlDataReader.get_MetaData() +96
System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior,字符串 resetOptionsString) +297
System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior、RunBehavior runBehavior、布尔 returnStream、布尔 异步)+954
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior、RunBehavior、runBehavior、布尔返回流、字符串 方法,DbAsyncResult 结果)+162
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior、RunBehavior、runBehavior、布尔返回流、字符串 方法)+32
System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior 行为,字符串方法)+141
System.Data.SqlClient.SqlCommand.ExecuteReader() +89
System.Web.SessionState.SqlSessionStateStore.DoGet(HttpContext 上下文、字符串 id、布尔 getExclusive、Boolean& 锁定、TimeSpan& lockAge, Object& lockId, SessionStateActions& actionFlags) +516

[HttpException (0x80004005): 无法连接到 SQL Server 会话 数据库。]
System.Web.SessionState.SqlSessionStateStore.ThrowSqlConnectionException(SqlConnection 康,例外 e) +229
System.Web.SessionState.SqlSessionStateStore.DoGet(HttpContext 上下文、字符串 id、布尔 getExclusive、Boolean& 锁定、TimeSpan& lockAge, Object& lockId, SessionStateActions& actionFlags) +649
System.Web.SessionState.SqlSessionStateStore.GetItemExclusive(HttpContext 上下文、字符串 id、Boolean& 锁定、TimeSpan& lockAge、Object& lockId, SessionStateActions & actionFlags) +48
System.Web.SessionState.SessionStateModule.GetSessionStateItem() +117 System.Web.SessionState.SessionStateModule.BeginAcquireState(对象 源,EventArgs e,AsyncCallback cb,对象 extraData)+487
System.Web.AsyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +66 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155

【问题讨论】:

  • 我检查了 machine.config 文件,也没有参考。我还从我的 bin 文件夹中删除了所有旧的 dll。与 dev 完全同步,我什至没有同名的数据库

标签: asp.net sql-server


【解决方案1】:

您知道这是一个网络应用程序。您可以转到 IIS,停止所有网站,使数据库脱机,看看是否出现错误。如果你不能重现它,一些网站正在连接到数据库,而你没有检查它的源代码。然后,您可以一个一个地启动这些站点,直到它中断。

希望对你有帮助!

【讨论】:

    【解决方案2】:

    您是否清理过您的解决方案?尝试清洁它,然后重建它。此外,您需要检查当您使该数据库重新联机时会发生什么情况。在您的 IIS 中检查可能引用此站点的任何连接字符串。

    【讨论】:

      【解决方案3】:

      HttpException (0x80004005): Unable to connect to SQL Server session database 表示您正在/正在使用 SQL Server 存储会话状态。在您的 web.config 中查找 configuration -> system.web 下的 sessionState 元素。如果mode 属性设置为SQLServer,那么将有一个带有连接字符串的sqlConnectionString 属性。您可以将模式从 SQLServer 更改为 InProc 以移至内存解决方案并远离 SQL Server。对于负载平衡环境,您必须坚持使用 SQL Server 或内存状态服务器。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2014-05-03
        • 2012-07-28
        • 2023-01-12
        • 2010-10-22
        • 1970-01-01
        • 1970-01-01
        • 2011-12-04
        相关资源
        最近更新 更多