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#
Developer technologies | C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
{count} votes

Answer accepted by question author
  1. Tom Phillips 17,781 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' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.