The error you are getting has nothing to do with SQL Server. It is a problem on your machine with your assemblies.
Open connection to server not working
Hello)
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);
sqlConnection.Open();
SqlCommand command = new SqlCommand(sqlExp, sqlConnection);
sqlConnection.Close();
}
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=5.0.0.0, 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?
1 additional answer
Sort by: Most helpful
-
Viorel 114.7K Reputation points
2022-02-27T20:57:30.54+00:00 If you are using the classes from Microsoft.Data.SqlClient, then try using System.Data.SqlClient, or vice versa.