Reputation: 31
Ok, so the problem is VSCode won't connect to the server, mssql extension is installed.
I have used localhost as the server name, tried with Integrated login, wouldn't connect. Tried with SQL Login, with User Name SA and sa, and passwords "", "sql", "SQL". Used all combinations.
Does anybody have any idea what's going on? Is there something I have to set up before I start connecting to the server?
Upvotes: 3
Views: 4522
Reputation: 171
I use the mssql extension with VSCode on a Macbook, and this is how I got it to work...
As John Pankowicz mentioned, you can add your connections directly into the settings.json file which lives in your .vscode folder (user profile or workspace level).
On my Mac, I must specify the protocol to use for connecting to the SQL Server on our domain, which in my case, is tcp.
Also, you may specify a profileName for each of your database connections if your server names are very cryptic and difficult to remember.
So an entry in my settings.json looks like this:
"mssql.connections": [
{
"profileName": "FOOBARDEV",
"authenticationType": "Integrated",
"trustServerCertificate": true,
"server": "tcp:foosql28.foobar.com\\edsql281,581"
}]
Once defined, the connection appears in the VsCode sidebar within the CONNECTIONS section of the SQL Server extension listed by profile name.
Alternatively, you can define an ADO.NET connection string:
"mssql.connections": [
{
"profileName": "FOOBARDEV",
"connectionString": "data source=tcp:foosql28.foobar.com\\edsql281,581;Integrated Security=True;initial catalog=Foo; Trust Server Certificate=True"
}]
Upvotes: 2
Reputation: 4441
If, for example, you are using LocalDb, add this to your User settings.json file in VsCode:
"mssql.connections": [
{
"server": "(localdb)\\mssqllocaldb",
"database": "YourDatabaseName",
"authenticationType": "Integrated",
"profileName": "YourProfileName",
"password": ""
}
]
"YourProfileName" is anything you want. It shows up in Object Explorer.
Upvotes: 1