开发者

How to connect SQL Server 2008 with IIS 7 on Windows Server 2008

I am using Amazon EC2 server, with Windows Ser开发者_JAVA技巧ver. It has installed SQL Server 2008 R2 Express and IIS7. I have made a web site, and want to test this web app. But it is not connecting to the SQL Server. I have tried different connection strings. But it is giving this error:

Server Error in '/' Application. Cannot open database "Avon" requested by the login. The login failed. Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.

I have tried to change it from windows authentication to SQL Server authentication and vice versa. But same error.

My connection string is

connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|Avon.mdf;Integrated Security=True;User Instance=true;"

I have copied Avon.mdf and Avon.ldf file into App_data. I want it to connect either by local server, or by IP address.

I appreciate your answers. Thanks


If the identity under which the application is running does not have access to the database, you will need to provide user name and password in the connection string.

Example:
Password=somepassword;Persist Security Info=True;User ID=someuserid;Initial Catalog=DatabaseName;Data Source=.\SQLEXPRESS


You could also try changing your Application pool identiy to a user that has access to the database. or set up asp.net impersonation


Application pool on II7 work in context of user NETWORK SERVICE. In your connection string you have Integrated Security=True. Solutions: 1) Change connection string to use userId+password 2) Change application pool user - not recommended if you don't understand how it works 3) Allow user NETWORK SERVICE connect to your sql server\data base - not recommended because many others services use this technical account.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜