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

coure2011 picture coure2011 · Apr 4, 2010 · Viewed 343.2k times · Source

I have created a web service which is saving some data into to db. But I am getting this error:

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

My connection string is

Data Source=.\SQLExpress;Initial Catalog=IFItest;Integrated Security=True

Answer

marc_s picture marc_s · Apr 4, 2010

Well, the error is pretty clear, no? You are trying to connect to your SQL Server with user "xyz/ASPNET" - that's the account your ASP.NET app is running under.

This account is not allowed to connect to SQL Server - either create a login on SQL Server for that account, or then specify another valid SQL Server account in your connection string.

Can you show us your connection string (by updating your original question)?

UPDATE: Ok, you're using integrated Windows authentication --> you need to create a SQL Server login for "xyz\ASPNET" on your SQL Server - or change your connection string to something like:

connectionString="Server=.\SQLExpress;Database=IFItest;User ID=xyz;pwd=top$secret"

If you have a user "xyz" with a password of "top$secret" in your database.