Click here to Skip to main content
15,881,204 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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

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
 
Share this answer
 
Comments
ali_heidari_ 11-Oct-12 12:24pm    
ues its in my site place ... can you explain about second solution?
SQL
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.
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900