When you are experiencing the "Named Pipes provider Microsoft SQL server Error 40" try the below steps to resolve the issue
Step 1: Search for SQL Server Configuration manager, if unable to find/missed while installing it then install it
(SQLEXPR_x64_ENU.exe) this is for 64 bit version, you can install according to you computer's/ laptop's Configuration
Step 2: Go to Configuration Manager section and Enable the TCP/IP protocol
Step 3: Go to Control Panel -> Admin Tools -> Services -> Search for
MSSQLSERVER Service and restart it.
Step 4: Login back to SQL server management studio with proper instance name as
Server Name =.\SQLEXPRESS
Authentication: SQL Server Authentocation
Login: sa
Password: **********This will resolve the issue