首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

使用者程式碼未處理 System.Data.SqlClient.SqlException,该怎么解决

2013-10-11 
使用者程式碼未處理 System.Data.SqlClient.SqlException報以下錯誤,因小弟才開始接觸.net,所以還請各位能

使用者程式碼未處理 System.Data.SqlClient.SqlException
報以下錯誤,因小弟才開始接觸.net,所以還請各位能幫忙分析下
謝謝!!
----------------------------------報錯部分------------------------------
使用者程式碼未處理 System.Data.SqlClient.SqlException
  HResult=-2146232060
  Message=建立連接至 SQL Server 時,發生網路相關或執行個體特定的錯誤。找不到或無法存取伺服器。確認執行個名稱是否正確,以及 SQL Server 是否設定為允許遠端連線。 (provider: Named Pipes Provider, error: 40 - 無法開啟至 SQL Server 的連接)
  Source=.Net SqlClient Data Provider
  ErrorCode=-2146232060
  Class=20
  LineNumber=0
  Number=53
  Server=""
  State=0
  StackTrace:
       於 System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
       於 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
       於 System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, Boolean withFailover)
       於 System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, Boolean withFailover)
       於 System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString connectionOptions, SqlCredential credential, TimeoutTimer timeout)
       於 System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance)
       於 System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions)
       於 System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
       於 System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions)
       於 System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnectionOptions userOptions)
       於 System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnectionOptions userOptions)
       於 System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)
       於 System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)
       於 System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)
       於 System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
       於 System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
       於 System.Data.SqlClient.SqlConnection.Open()
       於 ConferenceRoomsBook.Common.TCsLocalSrv.GetDataTable(String SQL, String[] ParamNames, Object[] ParamValues) 於 E:\ConferenceRoomsBook\Common\TCsLocalSrv.cs: 行 78
       於 ConferenceRoomsBook.Common.TCsEmpInfo.GetEmpInfoByName(String empUserName) 於 E:\ConferenceRoomsBook\Common\TCsEmpInfo.cs: 行 31
       於 ConferenceRoomsBook._Default.DoInit() 於 E:\ConferenceRoomsBook\Default.aspx.cs: 行 25
       於 ConferenceRoomsBook._Default.Page_Load(Object sender, EventArgs e) 於 E:\ConferenceRoomsBook\Default.aspx.cs: 行 17


       於 System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)
       於 System.Web.UI.Control.OnLoad(EventArgs e)
       於 System.Web.UI.Control.LoadRecursive()
       於 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
  InnerException: System.ComponentModel.Win32Exception
       HResult=-2147467259
       Message=找不到網路路徑。
       ErrorCode=-2147467259
       NativeErrorCode=53
       InnerException:  問題;
[解决办法]
检查sql server是否启用tcp/ip协议,防火墙设置,你的连接字符串中的主机和sql server实例名是否正确。

热点排行