0

I have installed SQL Server (mssql) extension in my VS Code then tried to connect to SQL Server Express with ./SQLEXPRESS, master, integrated log in detail. It should work perfectly as by default there's a database named "master".

But instead I get two errors:

mssql: Error: Unable to connect using the connection information provided. Retry profile creation?

mssql: Error 3: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)

Please can anyone help me with that?

Expecting to connect VS Code with SQL Server Express

Dale K
  • 25,246
  • 15
  • 42
  • 71
  • https://stackoverflow.com/questions/1246749/sql-server-express-connection-string You seem to have type the wrong slash. It should be `.\SQLEXpress`. Delete this question if that's the cause, as questions caused by typos are of no value. – Lex Li Jan 15 '23 at 07:58
  • This is not the case. Even with the localhost\SQLEXPRESS it shows the same error. Have also checked the port that SQL Server Express is running on (default is 1433). Nothing is working till now. @LexLi – Anika Nawar Chowdhury Jan 15 '23 at 08:28
  • Can you connect to `.\SQLEXPRESS` using SQL Server Management Studio or Azure Data Studio? – marc_s Jan 15 '23 at 08:43
  • Are you certain there is a sql server running on localhost? It's a frequent mistake to only install client tools and not the server. Check your services and confirm it is installed and runnig – Nick.Mc Jan 15 '23 at 09:16
  • SQL Server Express doesn't listen on the TCP/IP protocol by default, it's disabled in SQL Server (version) Configuration Manager under the Server Protocols configuration for the instance. If you enabled the TCP/IP protocol, or modified the instance's protocols in any way, you have to restart both the SQL Express instance (for the changes to take effect) and the SQL Browser service (for the new configuration to be loaded). Also note that it's trying to connect using the Named Pipes provider instead of TCP/IP. You might want to check the 32/64 bit Client Protocols in SSCM and reprioritize them. – AlwaysLearning Jan 15 '23 at 09:50
  • @AlwaysLearning yes i tried to enable everything as well as per your comment earlier but still not working. And yes those were in disable mode by default – Anika Nawar Chowdhury Jan 15 '23 at 09:58
  • Well let's try ruling out the SQL Browser service first, as that's what's responsible for resolving instance names like `\SQLEXPRESS` to the actual port that the instance is listening on. Since you've already configured the SQL Express instance to listen on port 1433 using the TCP/IP protocol, in VS Code try setting the `Server name or ADO connection string property` to `127.0.0.1,1433`. Does the error message change? – AlwaysLearning Jan 15 '23 at 10:09
  • If your SQLEXPRESS instance is listening on the default 1433, you can omit the instance name. Try connecting to `.`. That will not use SQL Server Browser. – Dan Guzman Jan 15 '23 at 13:25
  • Thanks alwayslearning and @DanGuzman will definitely try these! – Anika Nawar Chowdhury Jan 16 '23 at 11:55

0 Answers0