我在我的工作站上运行了一个Windows服务,它是连接到数据库的供应商提供的工具的一部分。 它不会启动错误我得到4个错误在事件日志中有以下内部exception:
Inner Exception --------------- Type : System.Data.SqlClient.SqlException, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) Source : .Net SqlClient Data Provider Help link : Errors : System.Data.SqlClient.SqlErrorCollection Class : 20 LineNumber : 0 Number : 53 Procedure : Server : State : 0 ErrorCode : -2146232060 Data : System.Collections.ListDictionaryInternal TargetSite : Void OnError(System.Data.SqlClient.SqlException, Boolean) Stack Trace : 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 System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(Boolean openCondition, DbConnection storeConnectionToOpen, DbConnection originalConnection, String exceptionCode, String attemptedOperation, Boolean& closeStoreConnectionOnFailure)
当然,关键的一点是(提供者:命名pipe道提供程序,错误:40 – 无法打开连接到SQL Server)
但是,如果我做一个runas /user:serviceuser cmd我可以通过命名pipe道连接到服务器就好:
C:\Windows\system32>sqlcmd -S np:\\%%SERVER_NAME%%\pipe\sql\query 1> SELECT @@servername, db_name() 2> go -------------------------------------------------------------------------------- ------------------------------------------------ ------------------------------- -------------------------------------------------------------------------------- ----------------- SERVER_NAME master (1 rows affected)
我还采取了哪些其他故障排除步骤?
检查环缓冲区输出的连通性错误,并检查错误日志,如果你看到一个login失败的错误消息。 检查该工具正在使用的login名,并查看是否可以使用相同的login名login到SQL实例。 还要找出他们提供的服务器名称,看他们是否使用别名。