To start with, he should use Microsoft.Data.SqlClient which has superceded System.Data.SqlClient.
Since recent versions of Microsoft.Data.SqlClient defaults to require an encrypted connection, this may lead to other errors, but we will see.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Our Developer want to upgrade his website .net 8.0 from .net core 3.1, and downloaded System.Data.SqlClient (04.8.6),
Have fixed all issues in debug machine.
Problem occurs when published to the production website, has got the following error:
Win32Exception: The target principal name is incorrect.
SqlException: A connection was successfully established with the server, but then an error occurred during the login process. (provider: SSL Provider, error: 0 - The target principal name is incorrect.)
Further details form log is as below:
Microsoft.Data.SqlClient.SqlException (0x80131904): A connection was successfully established with the server, but then an error occurred during the login process. (provider: SSL Provider, error: 0 - The target principal name is incorrect.)
---> System.ComponentModel.Win32Exception (0x80090322): The target principal name is incorrect.
To start with, he should use Microsoft.Data.SqlClient which has superceded System.Data.SqlClient.
Since recent versions of Microsoft.Data.SqlClient defaults to require an encrypted connection, this may lead to other errors, but we will see.
Hi @Tommy Lau,
Try adding TrustServerCertificate=True;
or adding Encrypt=False
to your connection string.
Regards,
Zoe Hui
If the answer is helpful, please click "Accept Answer" and upvote it.