private static bool IsNamedPipeConnectionError(SqlException exception)
{
// See http://blogs.msdn.com/b/sql_protocols/archive/2007/05/16/named-pipes-provider-error-40-could-not-open-a-connection-to-sql-server-microsoft-sql-server-error-xxx.aspx
return exception.Class == 20 && (
exception.Number == 2 || // The system cannot find the file specified
exception.Number == 53 || // The network path was not found
exception.Number == 233 || // No process is on the other end of the pipe
false);
}