连接到SQL Server时出错

时间:2012-12-06 17:22:03

标签: sql-server-2005 iis-7 windows-server-2008

我从网络应用中遇到了令人沮丧的错误。我已经追了好两天了。在某些情况下,下面的错误是在数据访问尝试期间发生的。发生错误时,它会响应单击应用页面上的链接。奇怪的是,在运行跟踪时,您会看到SQL Server正在使用适当的参数调用相应的存储过程。在其他情况下,数据访问执行得很好。

我发现奇怪的一件事是应用程序事件日志警告的线程信息(如下所示)。 是模拟:设置为false,即使启用了ASP.Net模拟也是如此。当然,这可能只是让我不知道我在说什么。

非常感谢您提供的任何帮助或指导。

环境:Windows Server 2008 Standard,IIS7,.net 2.x,SQL Server 2005

=======================
=    Yellow Screen    =
=======================


A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified) 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Data.SqlClient.SqlException: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)

Source Error: 


Line 3892:
Line 3893:    Sub getRenewalInformation(ByVal EntityID As Integer)
Line 3894:        BLLParticipant.GetParticipantRenewalInformation(EntityID)
Line 3895:        BLLParticipant.GetAdditionalInfo(EntityID)
Line 3896:    End Sub


Source File: M:\VirtualWebs\Intranet\SafeAtHome\Participants.aspx.vb    Line: 3894 

Stack Trace: 


[SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)]
   System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +6256377
   System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +245
   System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, SqlConnection owningObject) +6270399
   System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64 timerExpire, SqlConnection owningObject) +181
   System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String host, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, Int64 timerStart) +6271242
   System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) +6271208
   System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) +354
   System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) +703
   System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options) +54
   System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject) +6272472
   System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject) +81
   System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) +1657
   System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +88
   System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +6275911
   System.Data.SqlClient.SqlConnection.Open() +258
   SafeAtHome.DAL.Participant.GetParticipantRenewalInformation(Int32 EntityID) in C:\code\web\SafeAtHome2011\SafeAtHome.DAL\Participant.vb:42
   SafeAtHome.BLL.Participant.GetParticipantRenewalInformation(Int32 EntityID) in C:\code\web\SafeAtHome2011\SafeAtHome.BLL\Participant.vb:38
   Participant.getRenewalInformation(Int32 EntityID) in M:\VirtualWebs\Intranet\SafeAtHome\Participants.aspx.vb:3894
   Participant.BindCombinedParticipants(DataSet dst) in M:\VirtualWebs\Intranet\SafeAtHome\Participants.aspx.vb:3962
   Participant.grdParticipantSearchActive_Select(Object sender, DataGridCommandEventArgs e) in M:\VirtualWebs\Intranet\SafeAtHome\Participants.aspx.vb:959
   System.Web.UI.WebControls.DataGrid.OnBubbleEvent(Object source, EventArgs e) +88
   System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +70
   System.Web.UI.WebControls.DataGridItem.OnBubbleEvent(Object source, EventArgs e) +110
   System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +70
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +29
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2981




--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.5420; ASP.NET Version:2.0.50727.5420 


=======================================
=    Application Event Log Warning    =
=======================================

Event code: 3005 
Event message: An unhandled exception has occurred. 
Event time: 12/6/2012 8:53:00 AM 
Event time (UTC): 12/6/2012 2:53:00 PM 
Event ID: 52ff4f11e1d64e59b020623619f93fe9 
Event sequence: 6 
Event occurrence: 1 
Event detail code: 0 

Application information: 
    Application domain: /LM/W3SVC/1/ROOT/SafeAtHome-1-129992790193691690 
    Trust level: Full 
    Application Virtual Path: /SafeAtHome 
    Application Path: M:\VirtualWebs\Intranet\SafeAtHome\ 
    Machine name: SOSDEVINTRA 

Process information: 
    Process ID: 5068 
    Process name: w3wp.exe 
    Account name: IIS APPPOOL\ASP.NET 2.0 

Exception information: 
    Exception type: SqlException 
    Exception message: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified) 

Request information: 
    Request URL: .../safeathome/Participants.aspx
    Request path: /safeathome/Participants.aspx 
    User host address: ::1 
    User: test 
    Is authenticated: True 
    Authentication Type: Forms 
    Thread account name: IIS APPPOOL\ASP.NET 2.0 

Thread information: 
    Thread ID: 3 
    Thread account name: IIS APPPOOL\ASP.NET 2.0 
    Is impersonating: False 
    Stack trace:    at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
   at System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, SqlConnection owningObject)
   at System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64 timerExpire, SqlConnection owningObject)
   at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String host, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, Int64 timerStart)
   at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance)
   at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance)
   at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection)
   at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options)
   at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject)
   at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject)
   at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject)
   at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
   at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
   at System.Data.SqlClient.SqlConnection.Open()
   at SafeAtHome.DAL.Participant.GetParticipantRenewalInformation(Int32 EntityID) in C:\code\web\SafeAtHome2011\SafeAtHome.DAL\Participant.vb:line 42
   at SafeAtHome.BLL.Participant.GetParticipantRenewalInformation(Int32 EntityID) in C:\code\web\SafeAtHome2011\SafeAtHome.BLL\Participant.vb:line 38
   at Participant.getRenewalInformation(Int32 EntityID) in M:\VirtualWebs\Intranet\SafeAtHome\Participants.aspx.vb:line 3894
   at Participant.BindCombinedParticipants(DataSet dst) in M:\VirtualWebs\Intranet\SafeAtHome\Participants.aspx.vb:line 3962
   at Participant.grdParticipantSearchActive_Select(Object sender, DataGridCommandEventArgs e) in M:\VirtualWebs\Intranet\SafeAtHome\Participants.aspx.vb:line 959
   at System.Web.UI.WebControls.DataGrid.OnBubbleEvent(Object source, EventArgs e)
   at System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)
   at System.Web.UI.WebControls.DataGridItem.OnBubbleEvent(Object source, EventArgs e)
   at System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)
   at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

1 个答案:

答案 0 :(得分:0)

尝试一些事情

  1. 检查网站运行的帐号。转到AppPools,然后在高级设置中,您应该能够更改它。将其更改为网络服务并尝试解决。

  2. 检查访问SQL Server的帐户是否具有对Sql Server的适当权限。