0

When I try to create my database the below error is returned.

A connection was successfully established with the server, but then an error occurred during the login process.

I'm using SQL Server with an ASP.NET Core WebAPI application.

Connection String:

Server=DESKTOP-SHN56GM;Database=web-convenio;User Id=sa;Password=751512;

The connection to the database is made, but the login process is not, the user and password are correct. I believe the problem is the SSL certificate, which my server does not have.

  • Try doing a search for that error message. – Squirrel Feb 16 '23 at 10:43
  • maybe this link : https://stackoverflow.com/questions/34430550/a-connection-was-successfully-established-with-the-server-but-then-an-error-occ – mehdi.loa Feb 16 '23 at 10:48
  • `User Id=root`? Are you sure the username and password are correct? This isn't MySQL or MariaDB, the "sys admin" user on Microsoft SQL Server is typically `sa`. – AlwaysLearning Feb 16 '23 at 11:20
  • If you're using `Microsoft.Data.SqlClient` 4.0 or later as your connection library then `Encrypt=true;` is a default connection property. Have a read through [Released: General Availability of Microsoft.Data.SqlClient 4.0](https://techcommunity.microsoft.com/t5/sql-server-blog/released-general-availability-of-microsoft-data-sqlclient-4-0/ba-p/2983346) to see what options you have available to you. – AlwaysLearning Feb 16 '23 at 11:23
  • After some tests I realized that when using SQL Server Management Studio I can make the connection by activating the `Trust server certificate` option, but in my connection string when passing `Trust Server Certificate=true`, another error is returned. `An exception has been raised that is likely due to a transient failure. Consider enabling transient error resiliency by adding 'EnableRetryOnFailure' to the 'UseSqlServer' call.` – Douglas Badaró Feb 16 '23 at 13:03
  • Try this. `Data Source=DESKTOP-SHN56GM;User ID=sa;Password=751512;database=web-convenio;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False` – Jason Pan Feb 17 '23 at 09:52

1 Answers1

0

Based on the information you have provided, It is possible that the issue could be related to SSL Certificate, as the server does not have one. In that case you can try disabling the SSL Encryption in the connection string.

Example:

Server=DESKTOP-SHN56GM;Database=web-convenio;User Id=sa;Password=751512;Encrypt=False;

If this does not resolve the issue, Check the SQL Server error logs for any additional information on the login failure.

Check this:A connection was successfully established with the server, but then an error occurred during the login process. (Error Number: 233)