windows身份验证登入数据库 iis 无法访问数据库

系统 2108 0

原文地址: http://www.cnblogs.com/d-xtl/archive/2011/12/27/2303890.html

System.Data.SqlClient.SqlException: 用户'pc-2009\ASPNET' 登录失败的解决办法 
今天发布网站的时候遇到这个问题,多方查询后终于找到答案!

System.Data.SqlClient.SqlException: 用户'pc-2009\ASPNET' 登录失败的解决办法: (此处的PC-2009是我的机器名)

由于他的数据库连接语句中没有采用用户名和密码验证,采用的是windows集成验证,所以无法连接数据库。

解决方法很简单,加上ASPNET这个账号,赋予权限即可,具体方法如下:

1、企业管理器--》安全性--》登陆--》(右键)新建登陆--》名称(在列表中添加ASPNET这个用户);

2、然后在服务器角色一栏中选择System Administrators;

3、在数据库访问一栏中选择所要访问的数据库,然后在下面对话框中将db_owner选上,确定即可!

----------------------------------------------------------------------------------------------------------------------------------------

风筝:

在IIS中发布WebSite,然后连接SQLServer2005,采用windows身份验证数据库,结果访问数据库时报错,如下:

Server Error in '/PaidTimeOffUI' Application.


Cannot open database "HRPaidTimeOff" requested by the login. The login failed.
Login failed for user (ComputerName)\ASPNET'.

Description:  An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details:  System.Data.SqlClient.SqlException: Cannot open database "HRPaidTimeOff" requested by the login. The login failed.
Login failed for user 'ComputerName\ASPNET'.

-------------------------------------------------------------------

上网搜,有如下解释:

1、 http://p2p.wrox.com/book-asp-net-3-5-enterprise-application-development-visual-studio-2008-problem-design-solutio/80312-problem.html

2、...What I did to resolve this was, disable anonymous access, then enable digest authentication so IIS will look at the domain. In the realm area select or type your fully qualified domain and this should work....

http://p2p.wrox.com/book-asp-net-3-5-enterprise-application-development-visual-studio-2008-problem-design-solutio/73386-problem-compile.html

其中涉及到IIS配置,不懂~~于是按照上面方法在SQLServer中添加了ASPNET用户,得以解决,以后一定要学些IIS配置!

2012.02.21 晚

windows身份验证登入数据库 iis 无法访问数据库


更多文章、技术交流、商务合作、联系博主

微信扫码或搜索:z360901061

微信扫一扫加我为好友

QQ号联系: 360901061

您的支持是博主写作最大的动力,如果您喜欢我的文章,感觉我的文章对您有帮助,请用微信扫描下面二维码支持博主2元、5元、10元、20元等您想捐的金额吧,狠狠点击下面给点支持吧,站长非常感激您!手机微信长按不能支付解决办法:请将微信支付二维码保存到相册,切换到微信,然后点击微信右上角扫一扫功能,选择支付二维码完成支付。

【本文对您有帮助就好】

您的支持是博主写作最大的动力,如果您喜欢我的文章,感觉我的文章对您有帮助,请用微信扫描上面二维码支持博主2元、5元、10元、自定义金额等您想捐的金额吧,站长会非常 感谢您的哦!!!

发表我的评论
最新评论 总共0条评论