Thursday, July 30, 2009

Problem encountered when I run WEBSITE through IIS but not in VS2005 environment. Could you tel me please why?

Hello All


I am developing a site in ASP.Net2, C#.Net and SQLServer. It is running when I run this website from the Visual Studio 2005 environment. It uses inbuilt ASP.Net Server





But I am trying to run from the IIS it giving an error "System.Data.SqlClient.SqlException: Login failed for user 'ABCD\ASPNET'."





It shows when try to create connection with the SQLServer2000. Code is as follow





Dim myCon as new SQLConnection





myCon.ConnectionString=strConnectionst...


myCon.Open ---%26gt; Here giving error.





I am using


Database=SQLServer2000


Operating System=WinXP


Framework=2


Visual Studio 2005





thanks

Problem encountered when I run WEBSITE through IIS but not in VS2005 environment. Could you tel me please why?
When connecting to the database in visual studio, it is using a different account that has permissions to access the database. When run under IIS it is using the ASPNET user account, which does not have permission to access the database


To fix this, open up SQL Server Enterprise Manager and create a user for your database with the permissions that you require for the user (ie select,update,insert delete on the tables), and assign the user a password.





Then, in your connection string, specify the username and password to connect to the database with.


the url below has some info on connection strings


No comments:

Post a Comment