Error: 40- could not open a connection to SQL Server - in Visual Studio 2019

daowdos 296 Reputation points
2021-07-28T15:13:13.157+00:00

Hello everyone,
I can't connect to SQL Server inside Visual Studio 2019.
The Microsoft SQL by itself is connecting, its only inside visual studio.

I get error 40. I followed the steps and restart SQL in "Services" but that didn't help.

118668-sql-conncetion-missing.png118676-sql-sevices.png

What can I do to solve this ?

Thanks in advanced.

Error: 40- could not open a connection to SQL Server - in visual studio 2019

Windows for business Windows Server User experience Other
SQL Server Other
Developer technologies C#
{count} votes

Accepted answer
  1. Tom Phillips 17,771 Reputation points
    2021-07-28T16:29:50.893+00:00

    That error is a generic "could not connect to server" message and does not help in any way diagnose the actual problem.

    What exactly did you enter for the server name? Try "./sqlexpress", since your screen shot appears you have installed an instance named "sqlexpress".

    I suggest you start here:
    https://learn.microsoft.com/en-us/sql/database-engine/configure-windows/troubleshoot-connecting-to-the-sql-server-database-engine?view=sql-server-ver15#testing-a-local-connection

    2 people found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.