问题
Hi when I try to connect to a Microsoft SQL Server 2008R2 using System.Data.SqlClient from a Windows Universal Platform App I get following exception:
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)'
This is my connection string, I'm using SQL Authentification:
string connectionString = "{Data Source=xxx.xxx.xxx.xxx; Initial Catalog=TheDatabase;Integrated Security=false;User ID=user;Password=Password}"
When I try to connect to a 2016 SQL Server everithing works, here is my code:
using (SqlConnection connection= new SqlConnection(connectionString))
    {
        connection.Open();
    }
The exception is been thrown at connection.Open()
Things to consider:
- I've already set all needed premission in the Package.appxmanifest (enterpriseAuthentication, privateNetworkClientServer)
 - The SQL server has both Windows and SQL Authentification and has TCP enabled
 - The target version of the package is Windows 10 Fall Creators Update(10.0; Bulid 16299)
 - I already tried Integrated Security = true, and the exception is the same
 - Other applications (non WUP) are working fine with the 2008R2 Server and are also C# apps with .NET
 
This thread explanes the same issue: link to the question
Could Service Pack 3 for SQL Server 2008R2 help?
Are there workarounds or better ways to make 2008R2 work with WUP?
回答1:
Installing 2008R2 Service Pack solved the issue. I tried to reproduce the problem on my local pc with 2008R2 Express. I reproduced the issue and after I did the update to 2008R2 Service Pack 2 Express everything worked flawlessly.
I'll install the Service Pack 3 on production and update you if it's working
来源:https://stackoverflow.com/questions/51087826/system-data-sqlclient-sqlexception-when-i-try-to-connect-to-sql-server-2008r2-wi