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

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

问题描述

System.Data.SqlClient.SqlException:’已成功与服务器建立连接,但是在登录过程中发生了错误。 (提供者:TCP提供程序,错误: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

  • 软件包.appxmanifest设置为


    • internetClient

    • internetClientServer

    • privateNetworkClientServer

    • enterpriseAuthentication

    • Remote Access is enabled
    • Firewall rules are in place
    • Target version is Windows 10 Fall Creators Update(10.0; Bulid 16299
    • Min version is Windows 10 Fall Creators Update(10.0; Bulid 16299
    • Package.appxmanifest is setup with
      • internetClient
      • internetClientServer
      • privateNetworkClientServer
      • enterpriseAuthentication

      代码:

      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,并且可以重现您的问题。我还用相同的代码片段,相同的SQL Server配置测试了UWP app与SQL Server 2017之间的连接,它工作得很好。因此,作为一种解决方法,我强烈建议您将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 App连接到远程SQL Server 2008提供程序:TCP提供程序,错误:0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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