There are 3 main error numbers given when attempting to establish communication with a SQL database:
Error 26
Error 26 indicates that the client was able to contact SQL on the designated server name, but then the login failed. This could be because the instance name is entered incorrectly, or the username/password is incorrect, or other similar failure of the login information.
Verify that the connection information was correct, and try adding the port number for the specific instance.
Error 0/Error 40
These are similar errors, both indicating a failure to connect. It is my belief that Error 0 is more an indication of failure to connect with the server machine at all, and Error 40 indicates that the machine was contacted, but then it was unable to communicate with SQL on that server.
Microsoft provides troubleshooting steps for both Error 0 and 40 in a single page, listed in order of increasing complexity, at this link: http://social.technet.microsoft.com/wiki/contents/articles/2102.how-to-troubleshoot-connecting-to-the-sql-server-database-engine.aspx