Saturday, February 25, 2012

"Login failed for user MyPC/ASPNET"

Hi

I created my DB in SQL 2005 Express in VS IDE. I have my app in IIS. When I try to use the DB (e.g. try to login a user in the app) it gives me the following error:

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

My guess was that I had to give permissions to ASPNET user so I did in SQL Server Management. Still not working! Checked my Connection string and I think it's fine...

connectionString="Data Source=.\SQLEXPRESS;Database=cvRepository;Integrated Security=True;User Instance=True"

Still not working!

Can anyone explain me what's wrong and to solve this?!

Try replacing Database=cvRepository withAttachDBFileName=|DataDirectory|cvRepository.mdfin your connectionString.

Hope this helps.

Mike

|||Do you have a database namedcvRepositoryon your SQL server? Or you're using a database file attached at runtime? Anyways you have to ensure the ASPNET account has login permission to the SQL server, as well as access permissions on the required database.|||

Hi

Tried using the AttachDBFileName but nothing:

<

addname="cvRepositoryConnectionString"connectionString="Data Source=.\SQLEXPRESS;AttachDBFileName=|DataDirectory|cvrepository.mdf;Integrated Security=True;User Instance=True"providerName="System.Data.SqlClient" />I don't understand much of this but I'll shoot out something... When running the app in debug mode (http://localhost:2431/cvRepository/Default.aspx) it creates an instance of the SQL Server but when not doing so (http://localhost/cvRepository/Default.aspx) it doesn't, that's why I can't access the DB. Is this correct? If so, how to solve it?

Any explanation/article would be helpful!

Thx

|||Try to add the ASPNET login to a member ofsysadminordbcreatorserver role.|||

Hi

Instead of using User Instances I defined a particular user to access the DB. Used this:

connectionString

="Server=.\SQLEXPRESS;Database=cvrepository;User ID=user1;Password=user1pass"

Thx for your help

Cheers

No comments:

Post a Comment