0

I'm trying to connect SQL Server on my local machine and get some data back.
Here's my code:

var sql = require("seriate");
var config = {
    "host":"127.0.0.1",
    "port": "1433",
    "user": "dba",
    "password": "test1234",
    "database": "TheWorldDB"
};

sql.setDefaultConfig(config);

sql.execute({
    query: "SELECT * FROM dbo.Trip"
}).then(function (results) {
    console.log(results);
}, function (err) {
    console.log("Something bad happened:", err);
});

And I get following error message:

SqlContext Error. Failed on step "result" with: "No connection is specified for that request."
code: 'ENOCONN'

I checked the DB table, password, query etc. Everything is correct, not sure why it's not connecting, There's little information I can find on line as well. Any advice will be appreciated.

3
  • Make sure that the user is the owner of the database Make sure that you're using mixed mode login on the database server itself. Make sure you're using the default port to access the database server on. Commented Apr 11, 2016 at 18:21
  • @Chris Hi, Christ, double-checked again, everything is correct. But I do notice that TCP/IP of sql server is disabled. Not sure if that will make a difference? Commented Apr 11, 2016 at 18:35
  • That does seem odd. I would go ahead and enable it. Commented Apr 11, 2016 at 18:56

2 Answers 2

3

To answer my own question: Check if TCP/IP is enabled for Sql Server, if not, enable it.

Go to SQL Server Configuration Manager, click sql server network configuration, then click Protocols for MSSQLSERVER. You should be able to see TCP/IP status.

My thought process: 1. Wrote a small piece of .net web application which connect to same db, works fine. 2. In command prompt, tried "ping x.x.x.x" works, fine, tried "telnet x.x.x.x 1433" connection failed.

If above answer doesn't solve your problem,check if username, password for db is correct, also if port number is right.

Sign up to request clarification or add additional context in comments.

Comments

3

I experienced the same issue. My problem was using "server" instead of "host" in my config object.

1 Comment

What is the difference between using "server" vs "host"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.