Click here to Skip to main content
13,349,997 members (49,779 online)
Rate this:
Please Sign up or sign in to vote.
hey guys ...
i have a database in my website and its using default user in local ,everything is good until i open database with my visualstudio and do my works on database then i close connection because website needs to use it ... but it will show me this error :
Cannot open user default database.Login failed.<br />
Login failed for user 'alir-PC\alir'.

if i restart sqlserver my problem will be solve but i dnt know why if i open database with visual studio then after it my website do not open it .... but until i didnt open database with visual studio my website work very well ...
whats problem?
Posted 11-Oct-12 3:01am
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Is the database on the place as your website, it might not be reading it, another thing to consider is that the SQL Server may not accept remote connections, you may have to change your settings in order for it to accept connections from your website
source.compiler 11-Oct-12 12:24pm
ues its in my site place ... can you explain about second solution?
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Basically the main reason of this error is the unavailability of default user database at the time of connection. It is possible that the database:
•   Is in suspect mode.
•   No longer exists.
•   Is in single user mode and the only available connection is already being used by someone else or by something else.
•   Has been detached.
•   Has been set to the RESTRICTED_USER state.
•   Is offline.
•   Is set to emergency status.
•   Does not have the login account mapped to a user or the user has been denied access.
•   Is part of a database mirror.

To resolve such error you must specify a valid, available database in the connection string. To avoid the error when the user's default database is unavailable, log on as a user who can modify logins. Then, change the user's default database to a database that is currently available for a connection.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web03 | 2.8.180111.1 | Last Updated 8 Aug 2014
Copyright © CodeProject, 1999-2018
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100