简体   繁体   中英

Cannot access my SQL Server database in my website using IIS

My connection string is correct. It works when I debug and run from inside Visual Studio.

My problem is that I need to browse my site from the IIS to be able to access my website from any PC in my network.

When I changed the application pool identity to localsystem , it worked. I am worried that it won't work on any PC in my network, because I have no means to test it.

Can you confirm whether or not it would work?

It sounds like you are connecting using windows authentication - ie: "Trusted Connection".

That is why you can connect using Visual Studio - you are using your credentials to connect.

You need to run or impersonate IIS with an account that can connect to SQL Server, or allow IIS to impersonate the connected user, assuming they also have SQL server connection permissions.

您需要像这样在连接字符串中添加用户名和密码

Data Source='server IP';Initial Catalog='database name';Persist Security Info=True;User ID='your user name';password='your password

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM