The default configuration of the SQL Server 2005 doesn't allow remote connections. Hence, the error message "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)" when creating a new SQL Server database or connecting to an existing database in Visual Studio 2005 (VS2005).
To manually enable remote connections on the SQL Server,
1. Open the SQL Server Surface Area Configuration through Start menu.
2. Next, select Surface Area Configuration for Services and Connections.
3. On the left panel, expand the SQL Server instance -> Database Engine -> Remote Connections. Then, on the right panel, select Local and remote connections - Using TCP/IP only.
4. Also, make sure that the SQL Server Browser service is running.
5. Finally, restart the SQL Server instance. This can be done in the Services list under Administrative Tools in Control Panel.