本文介绍了用asp.net访问数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

am使用vs2008用sqlserver开发asp.net应用程序.当我从vs2008运行该应用程序时,它运行良好.但是将其发布到我的本地iis文件夹(即C:\ inetpub \ wwwroot)之后,它无法访问数据库.

我应该怎么办?我必须更改我的连接字符串吗?这是一个正在使用的计算机:

am developing an asp.net application with sqlserver using vs2008. When i run the application from vs2008, it works fine. But after publishing it to my local iis folder (i.e. C:\inetpub\wwwroot), it could not access the database.

What should i do? Do i have to change my connection string?? This is the one am using:

SqlConnection conn = new SqlConnection("Data Source=salisu-pc\\sqlexpress;Initial Catalog=NNPC;Integrated Security=True;Pooling=True");



[OP的答案移至问题]
谢谢.生成此异常:

System.Data.SqlClient.SqlException:无法打开登录请求的数据库"NNPC".然后登录失败.
用户"IIS APPPOOL \ DefaultAppPool"登录失败



[OP''s Answer moved to question]
thanks. The generating this exception:

System.Data.SqlClient.SqlException: Cannot open database "NNPC" requested by login. Then login failed.
Login failed for user "IIS APPPOOL\DefaultAppPool"

推荐答案



这篇关于用asp.net访问数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-28 03:17