I try to connect to a SQL Server 2008 instance with SQL Server credentials.
With a WPF app, I have no problem.
I follow this example: https://docs.microsoft.com/en-us/windows/uwp/data-access/sql-server-databases
I have read this: How to connect to SQL server database from a Windows 10 UWP app
My connection string is:
static private string connectionString =
@"Data Source=SERVER\SQLSERVER;Initial Catalog=Something;
Integrated Security=false;Persist Security Info=True;User ID=user;Password=pass";
conn = new SqlConnection(connectionString);
try
{
conn.Open();
}
catch(Exception z)
{
Debug.WriteLine(z.ToString());
}
I get this error
System.Data.SqlClient.SqlException (0x80131904): A connection was successfully established with the server, but then an error occurred during the login process. (provider: TCP Provider, error: 0 - L’opération a réussi)
If I try
static private string connectionString =
@"Data Source=SERVER\SQLSERVER;Initial Catalog = Something;
Integrated Security=true;User ID = user;Password= pass";
I get this error
System.Data.SqlClient.SqlException (0x80131904): Failed to generate SSPI context. ErrorCode=DowngradeDetected
The same error with Integrated Security=SSPI
If someone has an idea please?
Thanks Benoit
You need to check the appropriate capabilities in your appx manifest that are required for accessing the resource on your network. Open Package.appxmanifest in VS and go to the 'Capabilities' tab.
Try this code
optionsBuilder.UseSqlServer("Data Source = SERVER\SQLSERVER; Initial Catalog = Something; Integrated Security = False; User Id = user; Password = pass; MultipleActiveResultSets = True");
Make sure that the TCP is enabled in the SQL Server Configuration Manager
I remember The case can be solved by installing a small repair for the server Before that, try another server
I remembered the third case Install Kerberos See link https://support.microsoft.com/en-us/help/811889/how-to-troubleshoot-the-cannot-generate-sspi-context-error-message Download and install from the link https://www.microsoft.com/en-us/download/details.aspx?id=39046
I try with a new VM and SQL EXPRESS 2014 It's working.
I think UWP and SQL SERVER 2008 are not compatible.
Thanks for your help Rami.
Benoit
User contributions licensed under CC BY-SA 3.0