I am having error while connecting to SQL Server:
Details in Stack Trace are:
===================================
Cannot connect to ServerN
This is what helped me [src]:
My problem resolved by this what changes i have done in .net core Do this changes in Appsetting.json
Server=***;Database=***;Persist Security Info=False;User ID=***; Password=***;MultipleActiveResultSets=False;Encrypt=False;TrustServerCertificate=False;Connection Timeout=30
and Do following changes in Package console manager
Scaffold-DbContext "Server=***;Database=***;Persist Security Info=False;User ID=***; Password=***;MultipleActiveResultSets=False;Encrypt=False;TrustServerCertificate=False;Connection Timeout=30;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models -Context DatabaseContext -f
Happy coding
I got that error message in code line containing SqlConnection.Open()
running my .NET code as x64 application. Running as x86 causing no errors.
Solution was to deactivate the Force protocol encryption
option for TCP/IP in
%windir%\System32\cliconfg.exe
Force protocol encryption
In my case I had the following by mistake in my connection string:
Encrypt=True
Changing to
Encrypt=False
Solved the problem
"Server=***;Initial Catalog=***;Persist Security Info=False;User ID=***;Password=***;MultipleActiveResultSets=False;Encrypt=False;TrustServerCertificate=False;Connection Timeout=30;"
Turn out to be some SQL service was stopped somehow on server. Restarting SQL Server service manually was the solution.
I know this is foolish but worked anyway. Thanks @PareshJ for the useful comment.
From here:
Root Cause: Maximum connection has been exceeded on your SQL Server Instance.
How to fix it...!
- F8 or Object Explorer
- Right click on Instance --> Click Properties...
- Select "Connections" on "Select a page" area at left
- Chenge the value to 0 (Zero) for "Maximum number of concurrent connections(0 = Unlimited)"
- Restart the SQL Server Instance once.
Apart from that also ensure that below are enabled: