且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

无法打开用户默认数据库

更新时间:2023-02-03 10:09:18

数据库是否作为您的网站,它可能没有读取它,另一件需要考虑的事情是SQL Server可能不接受远程连接,您可能需要更改您的设置才能使它接受来自您网站的连接

>

基本上 此错误的主要原因 不可用  默认 用户 数据库位于时间  连接。它可能 
可疑模式下。
•不再存在
用户 mode 唯一可用的连接 已被使用 by 某人其他 其他
•已分离。
•已经设置 到RESTRICTED_USER状态。
离线。
设置 紧急状态。
是否将登录帐户映射到 用户 用户已被拒绝访问。
部分 数据库镜子。

解决此类错误,您必须指定有效的,可用的数据库 连接字符串中的class =code-keyword>。 避免错误 用户 ' s默认数据库不可用,以可以修改登录的用户身份登录。然后,更改用户' s 默认 数据库 数据库 目前可用用于连接。


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?

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


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.