Visual Studio Code mssql extension won't connect to the server - sql-server

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?

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.

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"
}]

Related

PostgresException: 3D000: database "kap_dev" does not exist

I am using serenity with postgres and I have generated a new project using visual studio 2019.
I have followed the tutorial of how to make the app connect with Postgresql.
I have created a new database and user in PgAdmin.
I have enabled the app to run migrations when I run my app.
Here is a sample of my connection string.
"Data": {
"Default": {
"ConnectionString": "Server=localhost; Port=5432; User Id=kap_dev; Database=kap_db; Password=kapap_password;",
"ProviderName": "Npgsql"
}
However, I get the error
PostgresException: 3D000: database "kap_dev" does not exist.
The issue is that kap_dev is a user and not a database.
I even posted this error to their git-issues but serenity have not responded with a valid answer.
might be a typo, no space between User and Id
You have to create a database which name is the name of your user "kap_dev".

Password authentication failed for user "postgresql"

Pls I have downloaded postgresql for Windows and I want to connect my models in Django model file to postgresql database but it keep throwing that error
Name : "django 1",
User: "postgresql",
Password: "bless90",
Host: "local host"
The result of those type of error is when u used a wrong word while passing the database config like the Name,User,Host,and password but for my case I used postgresql instead of postgres

How can I set application name when accessing SQL Server DB using Node.js mssql module?

I'm using the mssql module (https://www.npmjs.com/package/mssql) to access SQL Server databases. This is working pretty well, I can read/write/execute etc.
I can assign a login to the service I'm using, however I would also like to set the Application name property of the connection to something other than node-mssql, e.g. MyService.
I'm using a JSON config. file of the form
{
"user": "my_user",
"password": "my_password",
"server": "my_server",
"database": "my_database",
"port": 1433
}
Is is possible to add an additional property "application" or similar for this purpose? I can't find this in the docs for mssql.
In the link you provided it discusses an option for passing in a classic connection string.
In addition to configuration object there is an option to pass config
as a connection string. Two formats of connection string are
supported.
You are able to specific an Application Name in a standard SQL Server connection string.
"Application Name=MyAppName;"
Also, if you keep scrolling in the link you provided, there is an option for setting the application name using TDS. This of course assumes you are using the TDS driver.
options.appName - Application name used for SQL server logging.
Perhaps try something like this in your JSON?
{
"user": "my_user",
"password": "my_password",
"server": "my_server",
"database": "my_database",
"port": 1433
"options.appName": "name"
}
or
{
"user": "my_user",
"password": "my_password",
"server": "my_server",
"database": "my_database",
"port": 1433
"options": {
appName: name
}
}

What Registration Properties are needed to get Database Workbench up and running?

I am a Database Workbench fan from way back, but bizarrely have not used it for quite awhile.
I downloaded a trial version and am trying to "Register Server" as a first step.
The problem is I don't know what to use for which properties. I need to know:
Alias
Host
Instance
With "Use SQL Server Authentication" checked:
Username
Password
I've tried to guess my way through what is needed where, but nothing has worked.
I can connect to the database in (C#) code with this connection string:
"SERVER=PlatypusSQL42;DATABASE=duckbilldata;UID=youinnocentdog;PWD=contrasena;Connection Timeout=0";
And so I have tried these values:
Alias: DBWBSQLServer
Host: PlatypusSQL42
Instance: duckbilldata
Username: youinnocentdog
Password:contrasena
..and this:
Alias: PlatypusSQL42
Host: duckbilldata
Instance:
Username: youinnocentdog
Password:contrasena
...but with both of them, I get, "[DBNETLIB][ConnectionOpen (Connect()).]Specified SQL server not found."
What values are needed?
The instance is not the database in the server you are connecting to. You can actually have more than one Sql Server running in the same operating system. You're using the default instance, so don't use that field or leave it blank.
Host: PlatypusSQL42
Username: youinnocentdog
Password:contrasena

finding the correct connection string for a local SQL instance

I'm trying to build a connection string for a test environment that will connect to the local SQL Server instance on different machines. The purpose of this is so that a developer can checkout the code from TFS, build it, and run the testcases, connecting to his local DB. The problem is that different developer's machines may have different SQL Server setups. In particular, some may be running the full server, others may be running SQL Server Express.
I'm trying to right a utility routine that will take template connection string (e.g., Data Source=(local); Initial Catalog= myDB; Integrated Security=SSPI;) and modify the Data Source to work with the local server.
I've tried using SmoApplication.EnumAvailableServers() (returns an empty table, regardless of whether I user true or false parameters), and SqlDataSourceEnumerator.GetDataSources() (returns 2888 servers from the network, but none on the local machine), SQLCMD -L (returns nothing).
Any suggestions?
In the alternative, is there an easy way to tell whether a particular connection string will connect to a server (without waiting for it to timeout if it doesn't). If I could find the answer to that, I could try the likely suspects until I got one to work.
you might try to get the connection string as following:
Create a new blank file and name it test.udl.
Double click on it, and a "Data Link Properties" dialog should appear.
On "Providers" tab, select "Microsoft OLE DB Provider for SQL Server" or "SQL Native Client"
On "Connections" tab, try various settings and use the "Test Connection" button to test them. Click "Ok" when it works.
Open the test.udl file in Notepad and copy the line that starts with "Provider=" into your Web.config "ConnectionString" value, BUT delete the little part that says "Provider=SQLNCLI.1;"
If you want each developer to work with their own local SQL server, then the ADO connection string should have the Data Source set to localhost
... ; Data Source=localhost; ...
Additionally, to get a list of current servers, go to the command line and run
osql -L
You can look in the registry to find all local SQL Server instances. This key contains the list: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\Instance Names\SQL.
Each named instance will have a value in this key. For named instances the name of the value is the same as the name of the instance. For the default instance the value will be named MSSQLSERVER.
This will do the trick:
Data Source=.\SQLEXPRESS

Resources