Forum Discussion
Microsoft SQL: A connection was successfully established with the server, but then an error occurred
- 4 years ago
HI LucianoS ,
If you're getting this error after January 2022, possibly after migrating from
System.Data.SqlClienttoMicrosoft.Data.SqlClientor just updatingMicrosoft.Data.SqlClientto version 4.0.0 or later, it's because MS has introduced a breaking change::Breaking changes in 4.0
Changed
Encryptconnection string property to betrueby default.The default value of the
Encryptconnection setting has been changed fromfalsetotrue. With the growing use of cloud databases and the need to ensure those connections are secure, it's time for this backwards-compatibility-breaking change.Ensure connections fail when encryption is required
In scenarios where client encryption libraries were disabled or unavailable, it was possible for unencrypted connections to be made when
Encryptwas set totrueor the server required encryption.Rick Strahl has posted a detailed explanation on his blog
The change was made in this SqlClient pull-request in August 2021, where there is additional discussion about the change.
The quick-fix is to add
Encrypt=Falseto your connection-strings.Similar question refer:
Did I answer your question? Mark my post as a solution!
Best RegardsLucien
HI LucianoS ,
If you're getting this error after January 2022, possibly after migrating from System.Data.SqlClient to Microsoft.Data.SqlClient or just updating Microsoft.Data.SqlClient to version 4.0.0 or later, it's because MS has introduced a breaking change::
Breaking changes in 4.0
Changed
Encryptconnection string property to betrueby default.The default value of the
Encryptconnection setting has been changed fromfalsetotrue. With the growing use of cloud databases and the need to ensure those connections are secure, it's time for this backwards-compatibility-breaking change.Ensure connections fail when encryption is required
In scenarios where client encryption libraries were disabled or unavailable, it was possible for unencrypted connections to be made when
Encryptwas set totrueor the server required encryption.
Rick Strahl has posted a detailed explanation on his blog
The change was made in this SqlClient pull-request in August 2021, where there is additional discussion about the change.
The quick-fix is to add Encrypt=False to your connection-strings.
Similar question refer:
Did I answer your question? Mark my post as a solution!
Best Regards
Lucien