I was getting this error while hosting my project in IIS. I was not able to connect the database. Then i fix this error like this
Step 1: Go to Application Pools
Step2 : Select the application pool which one you have used
Step 3: Change the “identity” to LocalSystem
I hope this will help to somebody.