【问题标题】:System.Data.SqlClient.SqlException when I try to connect to SQL Server 2008R2 with a Windows Universal PlatformApp当我尝试使用 Windows 通用 PlatformApp 连接到 SQL Server 2008R2 时出现 System.Data.SqlClient.SqlException
【发布时间】:2018-06-28 16:40:48
【问题描述】:

您好,当我尝试使用 System.Data.SqlClient 从 Windows 通用平台应用程序连接到 Microsoft SQL Server 2008R2 时,出现以下异常:

System.Data.SqlClient.SqlException: '与服务器建立连接成功,但在登录过程中出现错误。 (提供者:TCP Provider,错误:0 - 操作成功完成)'

这是我的连接字符串,我正在使用 SQL 身份验证:

string connectionString = "{Data Source=xxx.xxx.xxx.xxx; Initial Catalog=TheDatabase;Integrated Security=false;User ID=user;Password=Password}"

当我尝试连接到 2016 SQL Server 时,一切正常,这是我的代码:

using (SqlConnection connection= new SqlConnection(connectionString))
    {
        connection.Open();
    }

connection.Open() 处抛出异常

需要考虑的事项:

  • 我已经在 Package.appxmanifest (enterpriseAuthentication, privateNetworkClientServer) 中设置了所有需要的权限
  • SQL 服务器同时具有 Windows 和 SQL 身份验证,并启用了 TCP
  • 该软件包的目标版本是 Windows 10 Fall Creators Update(10.0; Bulid 16299)
  • 我已经尝试过Integrated Security = true,异常也是一样
  • 其他应用程序(非 WUP)在 2008R2 服务器上运行良好,也是使用 .NET 的 C# 应用程序

这个帖子解释了同样的问题:link to the question

Service Pack 3 for SQL Server 2008R2 有帮助吗?

是否有解决方法或更好的方法使 2008R2 与 WUP 一起使用?

【问题讨论】:

  • 这个错误有很多可能的原因,我有点绝望。 This page 包括八个不同的选项,我至少看到了六个。您提到了检查 TCP/IP 是否已启用,但您是否检查了 SQL 浏览器服务已启用并处于活动状态?
  • 我检查了,它已启用:)

标签: c# sql-server sql-server-2008-r2


【解决方案1】:

安装 2008R2 Service Pack 解决了这个问题。 我试图用 2008R2 Express 在我的本地电脑上重现该问题。我重现了这个问题,在我更新到 2008R2 Service Pack 2 Express 之后,一切都完美无缺。

我将在生产环境中安装 Service Pack 3,如果它工作正常,我会更新您

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-06-16
    • 1970-01-01
    • 1970-01-01
    • 2022-11-26
    • 1970-01-01
    • 2021-06-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多