-1

I need to connect .Net Maui to Microsoft SQL Server 2019 I am not able to get connected. I am using package 'Microsoft.Data.SqlClient version 5.1.1'. It is giving error:

A connection was successfully established with the server, but then an error occurred during the pre-login handshake(provider: TCP Provider, error 35-An internal exception was caught).

Can you please give me any suggestion.

Thom A
  • 88,727
  • 11
  • 45
  • 75
Menghout
  • 1
  • 1
  • 3
    Please post the *full* exception, not just the message part. The inner exception may be telling you that the server's certificate isn't trusted for example. This can happen if you don't use a valid certificate in SQL Server. There are a lot of SO questions with that specific error message. – Panagiotis Kanavos Aug 31 '23 at 09:40
  • 1
    Have you tried anything in the top question of thesame error? https://stackoverflow.com/q/3270199/8837661 – Jannick Breunis Aug 31 '23 at 09:48
  • Microsoft.Data.SqlClient uses connection encryption by default to ensure nothing intercepts connections to the server. To ensure this, the server's certificate has to be validated. If the full exception complains about the certificate, *just for development purposes*, you can add `TrustServerCertificate=True` to the connection string. In production you should add a valid certificate though. Otherwise someone (eg a malicious proxy) could pose as the server using its own certificate and inspect the data before forwarding calls to the server – Panagiotis Kanavos Aug 31 '23 at 09:48
  • 1
    Does this answer your question? [A connection was successfully established with the server, but then an error occurred during the pre-login handshake](https://stackoverflow.com/questions/3270199/a-connection-was-successfully-established-with-the-server-but-then-an-error-occ) – Jannick Breunis Aug 31 '23 at 09:48

0 Answers0