将 UWP 应用程序连接到远程 SQL Server 2008 提供程序:TCP 提供程序,错误:0 [英] Connecting UWP App to Remote SQL Server 2008 provider: TCP Provider, error: 0

查看:21
本文介绍了将 UWP 应用程序连接到远程 SQL Server 2008 提供程序:TCP 提供程序,错误:0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

System.Data.SqlClient.SqlException: '与服务器成功建立连接,但随后在登录过程中发生错误.(provider: TCP Provider, error: 0 - 操作成功完成)'

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)'

我正在尝试使用 UWP APP 连接到 SQL Server 2008 R2 数据库.

I'm trying to connect to SQL Server 2008 R2 database with a UWP APP.

  • 已启用远程访问
  • 防火墙规则已到位
  • 目标版本是 Windows 10 Fall Creators Update(10.0; Bulid 16299
  • 最低版本为 Windows 10 Fall Creators Update(10.0; Bulid 16299
  • Package.appxmanifest 设置为
    • 互联网客户端
    • internetClientServer
    • 私有网络客户端服务器
    • 企业认证

    代码:

    using System.Data.SqlClient;
    
    const string ConnectionString = "SERVER = XXXServer; DATABASE =     XXXDatabase; USER ID = XXXUser; PASSWORD = XXXPass";
    
    using (SqlConnection sqlConn = new SqlConnection(ConnectionString))
            {
                sqlConn.Open();
    
            }
    

    推荐答案

    我测试了 UWP 应用和 SQL server 2008 R2 之间的连接,可以重现您的问题.我还测试了 UWP 应用程序和 SQL Server 2017 之间的连接,使用相同的代码片段,SQL Server 的相同配置,效果很好.因此,作为一种解决方法,我强烈建议您将 SQL Server 升级到 2017,因为 SQL Server 2008 R2 已经过时了 不支持.

    I tested the connection between UWP app and SQL server 2008 R2, and can reproduce your issue. I also tested the connection between UWP app and SQL server 2017, with the same code snippet, same configuration for SQL server, it worked very well. So that as a workaround I strongly recommend you to upgrade the SQL server to 2017 since SQL server 2008 R2 is already out of date that not supported.

    此外,不要忘记启用SQL Server 的 TCP/IP 网络协议 你在上面的描述中没有提到它.

    Additionally, don't forgget to Enable TCP/IP Network Protocol for SQL Server which you didn't mention it in above description.

    这篇关于将 UWP 应用程序连接到远程 SQL Server 2008 提供程序:TCP 提供程序,错误:0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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