c# - 无法打开登录请求的数据库 "Test"。登录失败。用户 'sa' 登录失败

标签 c# sql-server

首先,我尝试搜索类似问题的答案:Developer Command Propmt 和这个: Cannot open database "test" requested by the login. The login failed. Login failed for user 'xyz\ASPNET' 我什至格式化了我的电脑。但我仍然有这个问题。很长一段时间我的应用程序连接到本地 MSSQl 服务器没有任何问题。但有一刻我决定使用 Server Menager 删除我的数据库。这开始发生了。 我要连接的 C# 代码(它在我决定删除数据库并替换它之前有效):

using (SqlConnection con = new SqlConnection(@"Server=tcp:DESKTOP-56F50SS;Database=Test;
User ID=sa;Password=Temptemp;Trusted_Connection=False;Encrypt=False;"))

最佳答案

看来我们无法设置 TCP/IP 的权限。请检查 TCP/IP 的权限。

启用TCP/IP网络协议(protocol)

Start SQL Server Configuration Manager. Click Start, point to All Programs, and click Microsoft SQL Server. Click Configuration Tools, and then click SQL Server Configuration Manager.

In SQL Server Configuration Manager, in the console pane, expand SQL Server Network Configuration.

In the console pane, click Protocols for .

In the details pane, right-click TCP/IP, and then click Enable.

In the console pane, click SQL Server Services.

In the details pane, right-click SQL Server (), and then click Restart, to stop and restart the SQL Server service.

关于c# - 无法打开登录请求的数据库 "Test"。登录失败。用户 'sa' 登录失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48435048/

相关文章:

sql-server - 将 sql-server datetime2 与 TADOQuery.open 结合使用

c# - IIS 8.0 HTTP 错误 404.17 - 未找到请求的内容似乎是脚本,不会由静态文件处理程序提供服务

c# sizeof 十进制?

c# - 在 C# 中计算阶乘

sql - 如何使用静态数据填充 sql 中缺失的行?

sql - 为什么我不能使用变量代替字符串作为参数

sql-server - 每小时自动恢复数据库的最佳方法

c# - 使用参数安全调用多次调用泛型方法(运行时返回类型)的最佳方法

c# - 序列化对于对象大小估计可靠吗?

c# - LinqToSQL - ToList() 似乎很慢