Open connection to server not working

Salavat 121 Reputation points

In a UWP app, pulled a button onto the canvas. In the Click handler I wrote the following code (Parl_DB_SP - database name, Table_1 - table name):

private void cl_OpenSQLconnect(object sender, RoutedEventArgs e)
             string connectionString = "Data Source=DESKTOP-D5Q\\SQLEXPSSH;Initial Catalog=Parl_DB_SP;Integrated Security=SSPI;";
             string sqlExp = "INSERT INTO Table_1 (Name,Year) VALUES ('Name',56)";
             SqlConnection sqlConnection = new SqlConnection(connectionString);
             SqlCommand command = new SqlCommand(sqlExp, sqlConnection);

but this code does not work - it shows an error in the sqlConnection.Open( ) line:
System.IO.FileLoadException: 'Could not load file or assembly 'System.Security.Principal.Windows, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)'
I'll note right away: TCP / IP is enabled, as is the database service.

What could be the problem?

Universal Windows Platform (UWP)
SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
12,911 questions
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,564 questions
0 comments No comments
{count} votes

Accepted answer
  1. Tom Phillips 17,716 Reputation points

    The error you are getting has nothing to do with SQL Server. It is a problem on your machine with your assemblies.


    2 people found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Viorel 113.1K Reputation points

    If you are using the classes from Microsoft.Data.SqlClient, then try using System.Data.SqlClient, or vice versa.

    2 people found this answer helpful.