Sublime Forum

SQLTools - Connecting to db not working

#1

I have installed SQLTools and setup the configuration to point to the database. I’m getting the following errors everytime I run a command:

Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : SQL Server Network Interfaces: Error Locating Server/Instance Specified [xFFFFFFFF]. .
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Login timeout expired.
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online…

The setup here is I’m on a local computer, and the database is on a remote server. The server is on-prem, and I can ping the server name. I’m not sure if I have the setting configurations setup. I have the following:

{
“connections”: {
“ConnectionName”: {
“type” : “mssql”,
// use either (“host”, “port”) and remove “instance”
// or (“host”, “instance”) and remove “port”
“host” : “nameofserver”,
“instance”: “nameofserver”,
//“port” : 1433,
// “username” and “password” are optional (remove if not needed)
“username”: “theusername”,
“password”: “thepassword”,
“database”: “thedatabasename”,
“encoding”: “utf-8”
}
},
“default”: “ConnectionName”
}

I’m using Sublime Text version 4200 (Sublime Text 3?).

Does anyone see if I’m doing something wrong?

0 Likes

#2

I found out my issue. The server I’m connecting to is a MSSQL database server, so the underlying code you would use to connect to it is the “sqlcmd” function (you can use that in command prompt).

The settings were incorrectly formatted, as my server has no instance name. I just use the host. I had to change this line:
“args_optional”: ["-S “{host},{port}”", “-S “{host}\{instance}””, “-U “{username}””, “-P “{password}””],

to this:
“args_optional”: ["-S “{host},{port}”", “-S “{host}””, “-U “{username}””, “-P “{password}””]

Here is my full overridden settings for SQLTools.sublime-settings:

// Settings in here override those in "SQLTools/SQLTools.sublime-settings"
{
	"show_result_on_window": false,
	"focus_on_result": false,
	"use_streams": false,
	"format": {
		"indent_tabs"     : false
    },
    "debug": false,
    "cli_options": {
    	"mssql": {
    		"args_optional": ["-S \"{host},{port}\"", "-S \"{host}\"", "-U \"{username}\"", "-P \"{password}\""]
    	}
    }
}

Hopefully this helps someone in the future.

0 Likes