Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET SQL-Server
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.
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
good
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
  Permalink  
Comments
source.compiler at 11-Oct-12 12:24pm
   
ues its in my site place ... can you explain about second solution?
Rate this: bad
good
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.
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 406
1 /\jmot 180
2 Suraj Sahoo | Coding Passion 170
3 Afzaal Ahmad Zeeshan 159
4 BillWoodruff 154
0 OriginalGriff 8,344
1 Sergey Alexandrovich Kryukov 7,407
2 DamithSL 5,634
3 Maciej Los 5,024
4 Manas Bhardwaj 4,986


Advertise | Privacy | Mobile
Web04 | 2.8.1411023.1 | Last Updated 8 Aug 2014
Copyright © CodeProject, 1999-2014
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