Thursday, March 22, 2012

Cannot open user default database. Login failed.

Cannot open user default database. Login failed.
Login failed for user '[machine name]\ASPNET'.

I'm working in VS 2005 with a starter kit. I close VS and open an MDF file in SQL Server 2005 Management Studio to modify a table. I attach the file, change a data type, then detach the file. When I go back to VS and try to run the program, I get this error. Everything runs normally before I bring the file into Management Studio. It is not a permissions issue. Does SQL Server put some kind of lock on the file? This must be a fairly common problem. A developer will sometimes want to modify an .mdf file. How does he do that and then run his program? Thank you for any suggestions I can try.

What authentication is this instance. Post your connection string... this seems to be the problem with ASPNET user. The "ASPNET" user account is created in Windows XP by Microsoft .NET Framework. In the connection string you use a SQL Server Login and try.

From the link mentioned below :-

Applications that use SQL Authentication to connect to a database are not generally affected by using the ASPNET account. Applications that use integrated authentication and impersonation are also not generally affected. However, if an application is not impersonating and is using Integrated Authentication, you must grant access to the database for the ASPNET account.

You cannot use the ASPNET account when you try to authenticate to Microsoft SQL Server by using Integrated Authentication over named pipes. However, you can use the ASPNET account together with Integrated Authentication over the Transmission Control Protocol (TCP) transport.

If an application must use a Microsoft Access database, the ASPNET account must be able to write to the database file. Administrators must change the file permissions to allow this use.

Refer :

http://support.microsoft.com/kb/895967/

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=214866&SiteID=1

Madhu

|||

Hi

Seen that before.

Someone has modified your login or the default database is unavailable.

You can use the following command to log on using Query Analyser. Run it the in the RUN window.

Code Snippet

isqlw -S servername -E (-U username -P password if using sql login) -d master

This will log you on to master database and then you can check for any problems or reset the default database using sp_defaultdb.

hope that helps

Jag

No comments:

Post a Comment