用户'sa'登录失败。原因未能打开显式指定的数据库 [英] login failed for user 'sa'. reason failed to open the explicitly specified database

查看:553
本文介绍了用户'sa'登录失败。原因未能打开显式指定的数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我从客户端服务器遇到问题。



我开发了一个Windows应用程序,它接收来自diff设备的请求并连接到不同的API并更新数据库中的请求和响应以及WEB界面以检查记录状态,不同类型的报告



也是一个Windows服务,每5秒连接一次数据库并执行一些处理并更新对数据库的响应





突然发生了什么我不知道服务器上的所有端口都停止列表(无法接收请求),数据库连接失败



i从事件中发现此错误log ...用户'sa登录失败'。原因未能打开明确指定的数据库



可能是什么原因..



请帮帮我



谢谢大家。

Hi,

I am having an issue from the client server.

I have developed a windows application which receives requests from diff devices and connect to the different APIs and updates the request and responses in the database and also WEB interface to check the record status, different kinds of reports

also a windows service which connects to the database for every 5 seconds and do some process and update the response to the database


suddenly what happens i don't know all the ports on the server stopped listning (unable to receive the requests), database connection fails

i found this error from event log... "login failed for user 'sa'. reason failed to open the explicitly specified database"

what could be the reason..

please help me

Thanks to all.

推荐答案

首先检查你的连接是否全部关闭和Disposed:如果你没有这样做,那很可能是SQL连接耗尽 - 特别是如果你每隔5秒创建,打开和丢弃一个新连接...



使用块将您的SqlConnection放入块,看看是否可以改善:

Start by checking that your connections are all closed and Disposed: 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 every 5 seconds...

Put your SqlConnection into a using block and see if that improves things:
using (SqlConnection con = new SqlConnection(strConnect))
   {
   ...
   }


无法打开明确指定的数据库错误表示您的连接字符串指定了一个不存在或脱机的数据库。您需要检查SQL以找到正确的数据库名称。



更重要的是,您的应用程序从不以<$ c $连接C> SA
。您应该只使用运行应用程序所需权限最少的帐户进行连接。以 sa 连接可以让攻击者完全控制您的服务器。
The "failed to open the explicitly specified database" error means that your connection string specifies a database which doesn't exist, or is off-line. You'll need to check SQL to find the correct database name.

More importantly, your applications should never connect as sa. You should only ever connect using an account with the least permissions required to run your application. Connecting as sa could give an attacker complete control over your server.


这篇关于用户'sa'登录失败。原因未能打开显式指定的数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆