I have seen this error so many time so I thought that let me post the solution that work for me. First thing check your connection string that it points correct server. This is the most common mistake. Sometime connection string points to SQL Express, while machine does not have SQL Expressed installed.
If the connection string is correct, second step is to check congiguration of SQL. Click on Start – All Programms – Sql Server 2005 – Configuration Tool – SQL Server Configuration Manager. You can see the mmc as shown below,
Fig (1) – Sql Server Configuration Manager.
Click on SQL Server 2005 Network configuration – Protocols for MS SQL Server. Make sure that TCP/IP and Named Piped are Enable. If not that enable it. Now click on SQL Server 2005 Services. Restart Sql Server Browser Service and then restart SQL Server (MSSQLSERVER) service. Yupiiii !!! its all. Check your application now your error should be resolved.
Happy Programming !!