Just a note to myself and to any of you who faced the error like me earlier on..
“Cannot connect to localhost.
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 – Could not open a connection to SQL Server) (Microsoft SQL Server, Error: 2)”
I was thinking, its localhost and I used the right username / password combination ( Well, i was using Windows Authenication )… whats wrong? Took me a while to realise its because , for some reason, my MSSSQL Server Service got stopped.
I went to Start > All Programs > Microsoft SQL Server 2008 R2 > Configuration Tools > SQL Server Configuration Manager and right click on the stopped SQL Server and Start it.