Once you get the error check the trace file. It will give you more information about the connection failure. On that basis you can troubleshoot the issue.
In my case the path of sqlncli.dll is not found because the application is pointing to a different path and the sqlncli.dll was installed to a different location. After moving the file to that location our application was working fine.
Author : Mukesh(MSFT), Suport engineer, Microsoft
Reviewed by : Snehadeep(MSFT), SQL Developer Technical Lead, Microsoft