The error "error: 40 - Could not open a connection to SQL Server" istelf can be caused by several reasons. The
additional error code often helps to narrow down the problem.
For example, the original post lists this:
"... (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) (Microsoft SQL
Server, Error: 2)"
- error 40 is generated by the SqlClient provider, and is somehwat generic in this case.
- error 2 is the "winerror" that comes from the OS, and is more specific: ERROR_FILE_NOT_FOUND in this case
ERROR_FILE_NOT_FOUND most frequently indicates that the client attempted a connection to the *local* SQL
Server but the server is either not available, not running, or not accepting connections. One possibility is that
the server was specified as ".", "(local)" (or ".\SQLEXPRESS", "(local)\SQLEXPRESS"). If a connection to a remote
server is desired the actual name of the server must be used instead of ".".
With regard to connections to a default instance server that listens on a non-stadard TCP port: Client Network
Utility cannot be used to configure the default target TCP port used by .Net Fraemwork 2.0 (or VS2005). You
either need to specify the port in the connection string, e.g. if the port is 1500 you can specify
"targetServer,1500", or you can create an alias specifying the TCP port (here, Client Network Utility can be used).
No comments:
Post a Comment