我数据库用的EF做ORM,在vs里面测试的时候不会出现这个错误,用IIS就出错了。解决方法如下

Solution for "The underlying provider failed on Open" exception.

By venugopalm11 Nov 2010
 
 
But this is not the right solution and no one is saying how to fix the issue. After spending some hours, found the solution and my app running without any issues.
 

Here is the solution.
 

As folks mentioned IIS user network service user credentials while trying to log in sql server. So just change the Application pool settings in your IIS.
 
Step 1:
Open Internet Information Service Manager
Step 2:
Click on Application Pools in left navigation tree.
Step 3:
Select your version Pool. In my case, I am using ASP .Net v4.0. If you dont have this version, select DefaultAppPool.
Step 4:
Right click on step 3, and select advanced settings.
Step 5:
Select Identity in properties window and click the button to change the value.
Step 6:
Select Local System in Built-in accounts combo box and click ok.
That's it. Now run your application. Everything works well.
 
Enjoy!!!.

 

http://www.codeproject.com/Tips/126919/Solution-for-The-underlying-provider-failed-on-Ope?msg=4226646#xx4226646xx

相关文章: