Sunday, February 19, 2012

cant connect to sql server 2005 from my asp.net application

Hi

I can't connect to sql server 2005 from my asp.net web page. I seem to be able to connect to it when i run the application from within visual studio but i can't connect to it when i run the application from IIS.

I am new to sql server 2005 express so please bear with me.

The error message i get is:

Cannot open database "Vets" requested by the login. The login failed.
Login failed for user 'OSCAR2K4\ASPNET'.

I don't know where this user OSCAR2K4\ASPNET came from but i looked in sql server 2005 and there he is. In the left hand pane I went to Security and then logins and found oscar2k4\asp.net there. I went to the properties for this user and went to User Mappings. There was no tick next to my Vets database so I added one and ran the application from IIS. I also added the user to every single role in the vets database (including dbowner). I also went into the vets database itself and found the oscar/aspnet user and made sure he was added to every role.

I ran the application again. This time i got a lots of different errors. If the page was trying to run a select procedure I got the error user does not have select permission. If the page was running an SP i got the error or user does not execute permission


I have never had this problem before so I don't understand.

Where did this user come from? Was he created automatically when i configured my database for membership and roles? How do i set up this user so he can access the databsae from IIS.

The only way I could get the application to run from IIS was to go to Security - Logins for sql server and add the oscar2k4\asp.net user to the sysadmin role.

I find this very strange. Naturally i don't want to leave oscar2k4 in sysadmin.

Please help :) I can't upload my website until i fix this

Thanks, andrea

<server>\ASPNET is 'ASP.NET Machine Account', one of the access control lists (ACLs) that are set by default on the Machine.config file and the root Web.config file.

What's the OS version (e.g. Window2000 or Xp) of the box? You can take a look at this articlehttp://msdn2.microsoft.com/en-us/library/ab4e6cky.aspx

No comments:

Post a Comment