简体   繁体   English

无法打开登录请求的数据库“ Inventory_New”。 登录失败。 用户“ sa”的登录失败

[英]Cannot open database “Inventory_New” requested by the login. The login failed. Login failed for user 'sa'

I have made my database in SQL Server 2008 R2 Express Edition and the software is made in VS C# Windows Form and is used to store data of inventory of a big company. 我已经在SQL Server 2008 R2 Express Edition中建立了数据库,该软件是在VS C#Windows Form中制成的,用于存储大公司的库存数据。

I use a BackgroundWorker in the software to continuously check if the stock has been updated or not but for some reason it shows the below error. 我在软件中使用BackgroundWorker来连续检查库存是否已更新,但由于某种原因它显示以下错误。

Cannot open database "Inventory_New" requested by the login. 无法打开登录请求的数据库“ Inventory_New”。 The login failed. 登录失败。 Login failed for user 'sa'. 用户“ sa”的登录失败。

I have already gone through many blogs and article but none of the solution works for me. 我已经浏览了许多博客和文章,但是没有一种解决方案适合我。

I can login with Sql Server Management Studio with the user sa and it is responding well. 我可以使用用户sa登录Sql Server Management Studio,并且响应良好。

The software works just fine but throughout the day it randomly shows the above error (6-7 time a day no fixed time) 该软件运行正常,但全天随机显示上述错误(每天6-7次,无固定时间)

SQL Error Log SQL错误日志

Below is the error i found in SQL Error Log but i do not understand what that means 以下是我在SQL错误日志中发现的错误,但我不明白这意味着什么

2017-05-12 05:01:41.78 Logon Error: 18456, Severity: 14, State: 38. 2017-05-12 05:01:41.78登录错误:18456,严重性:14,状态:38。
2017-05-12 05:01:41.78 Logon Login failed for user 'sa'. 2017-05-12 05:01:41.78用户'sa'的登录登录失败。 Reason: Failed to open the explicitly specified database. 原因:无法打开显式指定的数据库。 [CLIENT: ] [客户:]

Edit 编辑

Lately i saw that when i got this error the database for some reason went in recovery mode . 最近,我看到当我收到此错误时, 数据库由于某种原因进入了恢复模式

I also checked some articles for why the Database goes in recovery mode but none of them seems to fit the bill because in my case the database comes online automatically after 2-3 seconds of short break. 我还检查了一些文章,以了解为什么数据库进入恢复模式,但似乎都不适合,因为在我的情况下,数据库在短暂中断2-3秒后自动联机。

Start by checking that your connections are all closed and Disposed. 首先检查您的连接是否已关闭并已处置。

Put your SqlConnection into a using block and see if that improves things: 将您的SqlConnection放入using块中,看看是否可以改善情况:

using (SqlConnection con = new SqlConnection(strConnect))
{
...
}

If you aren't doing that, it's quite likely that SQL has run out of connections - particularly if you are creating, opening, and discarding a new connection. 如果您不这样做,则很有可能SQL用尽了连接-特别是在创建,打开和丢弃新连接的情况下。

The error indicates you the database, Inventory_New, that can't be open. 该错误表明您无法打开数据库Inventory_New。 This means that your application asks for this database as the initial catalog, but the database is not online. 这意味着您的应用程序要求将此数据库作为初始目录,但该数据库不在线。 It can be in the middle of restore, for example, or just be offline. 例如,它可以在还原过程中,也可以仅处于脱机状态。 When you connect to server using Management Studio, you don't submit that database, I guess the default database for sa login is master, so you logged in successfully. 使用Management Studio连接到服务器时,您无需提交该数据库,我想sa登录的默认数据库为master,因此您已成功登录。 You should check why your Inventory_New database is not online 您应该检查为什么您的Inventory_New数据库不在线

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法打开登录请求的数据库“Test”。 登录失败。 用户'sa'登录失败 - Cannot open database “Test” requested by the login. The login failed. Login failed for user 'sa' 无法打开登录请求的数据库“”。 登录失败。 用户“ sa”的登录失败 - Cannot open database “” requested by the login. The login failed. Login failed for user 'sa' 无法打开登录请求的数据库“ [数据库]”。 登录失败。 用户“ [User]”的登录失败 - Cannot open database “[Database]” requested by the login. The login failed. Login failed for user '[User]" 无法打开登录请求的数据库“身份”。 登录失败。 用户“DESKTOP\User”登录失败 - Cannot open database “Identity” requested by the login. The login failed. Login failed for user 'DESKTOP\User' 无法打开登录请求的数据库“MyBase”。 登录失败。 用户“域\用户”登录失败 - Cannot open database "MyBase" requested by the login. The login failed. Login failed for user 'domain\User' 无法打开登录请求的数据库“ ASPState”。 登录失败。 用户“ xxxx”的登录失败 - Cannot open database “ASPState” requested by the login. The login failed. Login failed for user 'xxxx' 无法打开登录请求的数据库“test”。 登录失败。 用户 'Domain\\userid' 登录失败 - Cannot open database "test" requested by the login. The login failed. Login failed for user 'Domain\userid' 无法打开登录请求的数据库“ gainpeace”。 登录失败。 用户“ MALIK \\ ASPNET”的登录失败 - Cannot open database “gainpeace” requested by the login. The login failed. Login failed for user 'MALIK\ASPNET' 无法打开登录请求的数据库“ dbname”。 登录失败。 用户“ machinname \\ username”的登录失败 - Cannot open database “dbname” requested by the login. The login failed. Login failed for user “machinname\username” 无法打开登录请求的数据库。 登录失败。 用户“ NT AUTHORITY \\ SYSTEM”的登录失败 - Cannot open database requested by the login. The login failed. Login failed for user 'NT AUTHORITY\SYSTEM'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM