Nick
Nick

Reputation: 3100

Visual Studio Code mssql extention: SQL Server (mssql) - Unable to connect to server

I'm trying for the first time to get my project to run in Visual Studio Code. This includes a MySQL database. So I've installed the SQL Server (mssql) extension version 1.7.1. I follow the instructions here: https://learn.microsoft.com/en-us/sql/visual-studio-code/sql-server-develop-use-vscode?view=sql-server-ver15

I get to the section "Connect to SQL Server" and enter:

At the end of the section it should connect with the server but instead I get two errors:

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

mssql: Error 2: 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)

Does anyone see what is going wrong here? I've re-installed the extension but with the same result.

Upvotes: 2

Views: 17266

Answers (3)

Follow the steps:

In Visual Studio Code:

  1. Install the SQL server extension. After installation, you must see a box on the left panel of your VS Code screen. Select it.
  2. Add Connection
  3. Type Server name (from your MS SQL server) and hit Enter.
  4. Select Integrated
  5. Give your Connection Name and hit Enter.

Upvotes: 0

Hassan Elshazly Eida
Hassan Elshazly Eida

Reputation: 859

You should do the following

  1. install SQL server in your machine and create Database here

  2. Create a login and a database user here

  3. If you are Using VS code install SQL Server (mssql) open new connection, follow the prompts to specify the properties for the new connection profile

  4. If you want to login to your server to make sure of your data

    sqlcmd -S localhost -U SA -P '<YourPassword>'
    

Upvotes: 0

Peter Schneider
Peter Schneider

Reputation: 2939

A MySQL db and Microsoft SQL Server db are two different things.

It seems that there's no SQL Server installed? You might install the free SQL Server Express Version, create the database in there and then connect from Visual Studio Code.

You have to install the database server yourself as VS Code is just a client. You might also use somekind of hosted offers (many webhosters offer a mysql server with self service installation, or use a cloud based database server). Yout can also use a local database (e.g. SqlLite) which is file based and doesn't need a special installation.

Upvotes: 2

Related Questions