Named Pipes Provider, error: 40 - Could not open a

如果用SQLServer的SQLEXPRESS版本的话,连接时经常回遇到这个问题,查了很多终于找到了解决方法。

The typical error when dealing with Express includes:

a. User is not aware of SqlExpress was installed as a named instance, consequently, in his/her connection string, he/she only specify ".","localhost" etc instead of ".\SqlExpress" or "\Sqlexpress".

b. Np was disabld by default after installing SqlExpress.

c. If Sqlexpress was installed on the remote box, you need to enable remote connection for Express.

其中a的.\SqlExpress必须写在web.config文件中,如:

<connectionStrings>
<add name="NorthwindConnectionString" connectionString="Data Source=.\SqlExpress;Initial Catalog=Northwind;User ID=sa;Password=test"
   providerName="System.Data.SqlClient" />
</connectionStrings>

再用ConfigurationManager.ConnectionStrings["NorthwindConnectionString"].ConnectionString把connectionStrings从应用程序中读出来。如果直接把.\SqlExpress写在应用程序中如:SqlConnection conn = new SqlConnection("data source=.\ SqlExpress;initial catalog=Northwind;user id=sa;password=test")这样也是有错误的!

Please read the following blog for best practice of connecting to SqlExpress.

http://blogs.msdn.com/sql_protocols/archive/2006/03/23/558651.aspx

阅读更多

(provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server

10-07

以下是错误代码 (我的是SQL SERVER 2000不是2005)rnrnrnServer Error in '/' Application. rn-------------------------------------------------------------------------------- rnrnAn error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) rnDescription: 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. rnrnException Details: System.Data.SqlClient.SqlException: An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) rnrnSource Error: rnrnAn unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. rnrnStack Trace: rnrnrn[SqlException (0x80131904): An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)] rn System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +734979 rn System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +188 rn System.Data.SqlClient.TdsParser.Connect(Boolean& useFailoverPartner, Boolean& failoverDemandDone, String host, String failoverPartner, String protocol, SqlInternalConnectionTds connHandler, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, SqlConnection owningObject, Boolean aliasLookup) +820 rn System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) +628 rn System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) +170 rn System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) +359 rn System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options) +28 rn System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject) +424 rn System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject) +66 rn System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) +496 rn System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +82 rn System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +105 rn System.Data.SqlClient.SqlConnection.Open() +111 rn SqlServerTask.SQLHelper.PrepareCommand(SqlCommand cmd, SqlConnection conn, CommandType cmdType, String cmdText, SqlParameter[] cmdParms) +33 rn SqlServerTask.SQLHelper.ExecuteReader(String connString, CommandType cmdType, String cmdText, SqlParameter[] cmdParms) +111 rn SqlServerTask.MobileInfoTask.getInfo(String Code) +134 rn InterService.MobileInfoService.getInfo(String Mobile) +68 rn reg.Receive.accessAccount(String Mobile, String Message) +37 rn reg.Receive.Page_Load(Object sender, EventArgs e) +181 rn System.Web.UI.Control.OnLoad(EventArgs e) +99 rn System.Web.UI.Control.LoadRecursive() +47 rn System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1061 rn

Named Pipes Provider: Could not open a connection to SQL Server [1326].

04-28

在运行JOB的时候有两个JOB分别出现了如下两个报错,有劳大侠来帮忙看一下!rnrn报错是否是因为无法链接数据库?rnrnrnMessagernExecuted as user: yuanliu\prj-bi. Microsoft (R) SQL Server Execute Package Utility Version 10.50.2500.0 for 32-bit Copyright (C) Microsoft Corporation 2010. All rights reserved. Started: 0:30:00 Error: 2014-04-28 00:30:23.86 Code: 0xC0202009 Source: D_Customer Connection manager "YUANLIUSERVER.UFDATA_001_2012.yl" Description: SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80004005. An OLE DB record is available. Source: "Microsoft SQL Server Native Client 10.0" Hresult: 0x80004005 Description: "Login timeout expired". An OLE DB record is available. Source: "Microsoft SQL Server Native Client 10.0" Hresult: 0x80004005 Description: "A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online.". An OLE DB record is available. Source: "Microsoft SQL Server Native Client 10.0" Hresult: 0x80004005 Description: "Named Pipes Provider: Could not open a connection to SQL Server [1326]. ". End Error Error: 2014-04-28 00:30:23.86 Code: 0xC020801C Source: Customer UFIDA_TO_ODS Custome & CustomerClass & Department & districtClass & Person [1] Description: SSIS Error Code DTS_E_CANNOTACQUIRECONNECTIONFROMCONNECTIONMANAGER. The AcquireConnection method call to the connection manager "YUANLIUSERVER.UFDATA_001_2012.yl" failed with error code 0xC0202009. There may be error messages posted before this with more information on why the AcquireConnection method call failed. End Error Error: 2014-04-28 00:30:23.86 Code: 0xC0047017 Source: Customer UFIDA_TO_ODS SSIS.Pipeline Description: component "Custome & CustomerClass & Department & districtClass & Person" (1) failed validation and returned error code 0xC020801C. End Error Error: 2014-04-28 00:30:23.86 Code: 0xC004700C Source: Customer UFIDA_TO_ODS SSIS.Pipeline Description: One or more component failed validation. End Error Error: 2014-04-28 00:30:23.86 Code: 0xC0024107 Source: Customer UFIDA_TO_ODS Description: There were errors during task validation. End Error DTExec: The package execution returned DTSER_FAILURE (1). Started: 0:30:00 Finished: 0:30:23 Elapsed: 22.948 seconds. The package execution failed. The step failed.rnrnrnrnrnrnrnrnrnMessagernExecuted as user: yuanliu\prj-bi. Microsoft (R) SQL Server Execute Package Utility Version 10.50.2500.0 for 32-bit Copyright (C) Microsoft Corporation 2010. All rights reserved. Started: 1:01:19 Error: 2014-04-28 01:01:42.47 Code: 0xC0202009 Source: Fact_Finance Connection manager "YUANLIUSERVER.UFDATA_001_2012.yl" Description: SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80004005. An OLE DB record is available. Source: "Microsoft SQL Server Native Client 10.0" Hresult: 0x80004005 Description: "Login timeout expired". An OLE DB record is available. Source: "Microsoft SQL Server Native Client 10.0" Hresult: 0x80004005 Description: "A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online.". An OLE DB record is available. Source: "Microsoft SQL Server Native Client 10.0" Hresult: 0x80004005 Description: "Named Pipes Provider: Could not open a connection to SQL Server [1326]. ". End Error Error: 2014-04-28 01:01:42.47 Code: 0xC020801C Source: gl_accvouch YL_TO_ODS YL_gl_accvouch [1] Description: SSIS Error Code DTS_E_CANNOTACQUIRECONNECTIONFROMCONNECTIONMANAGER. The AcquireConnection method call to the connection manager "YUANLIUSERVER.UFDATA_001_2012.yl" failed with error code 0xC0202009. There may be error messages posted before this with more information on why the AcquireConnection method call failed. End Error Error: 2014-04-28 01:01:42.47 Code: 0xC0047017 Source: gl_accvouch YL_TO_ODS SSIS.Pipeline Description: component "YL_gl_accvouch" (1) failed validation and returned error code 0xC020801C. End Error Error: 2014-04-28 01:01:42.47 Code: 0xC004700C Source: gl_accvouch YL_TO_ODS SSIS.Pipeline Description: One or more component failed validation. End Error Error: 2014-04-28 01:01:42.47 Code: 0xC0024107 Source: gl_accvouch YL_TO_ODS Description: There were errors during task validation. End Error DTExec: The package execution returned DTSER_FAILURE (1). Started: 1:01:19 Finished: 1:01:42 Elapsed: 22.808 seconds. The package execution failed. The step failed.

换一批

没有更多推荐了,返回首页