System.Data.SqlClient.SqlException 当我尝试使用 Windows Universal PlatformApp 连接到 SQL Server 2008R2 时

System.Data.SqlClient.SqlException when I try to connect to SQL Server 2008R2 with a Windows Universal PlatformApp

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

System.Data.SqlClient.SqlException: 'A connection was successfully established with the server, but then an error occurred during the login process. (provider: TCP Provider, error: 0 - The operation completed successfully)'

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

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

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

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

在connection.Open()

处抛出异常

需要考虑的事项:

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

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

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

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

我会在生产环境中安装 Service Pack 3 并在它正常工作时更新你