UWP SQL connection Error [c#]

2

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

c#
sql-server
uwp
asked on Stack Overflow Apr 30, 2018 by Benoit • edited Apr 30, 2018 by marc_s

3 Answers

0

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.

answered on Stack Overflow Apr 30, 2018 by Stefan Wick MSFT
0
  1. Try this code

    optionsBuilder.UseSqlServer("Data Source = SERVER\SQLSERVER; Initial Catalog = Something; Integrated Security = False; User Id = user; Password = pass; MultipleActiveResultSets = True");

  2. Make sure that the TCP is enabled in the SQL Server Configuration Manager enter image description here

  3. I remember   The case can be solved by installing a small repair for the server Before that, try another server

  4. 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

answered on Stack Overflow Jul 12, 2018 by Rami Bancosly • edited Jul 14, 2018 by Rami Bancosly
0

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

answered on Stack Overflow Aug 13, 2018 by Benoit

User contributions licensed under CC BY-SA 3.0