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?
From what it looks like here you've got permission problems with the DB. Check the SQL Server and see if permissions are set for Windows Authentication, SQL Server Authentication or Mixed Mode. If you have Windows Authentication (and it sounds like that's what you've got - that or Mixed mode), you'll need to grant permissions to the ASPNET user to make a connection. If you are using SQL Server Authentication (or Mixed Mode if you prefer to manage logins from SQL Server) you'll need to add a login that can access the database and use it in your connection string.





In either case I'd strongly suggest you use stored procedures if possible for stronger security (though you'll still need to be careful when construction your stored procs if you use paramterized queries). Additionally (if you haven't done so) kill the sa account on the SQL Server box or at the very least change it's password if you don't want to get rid of it.


No comments:

Post a Comment