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.

Arulkumar
  • 12,966
  • 14
  • 47
  • 68
user1491987
  • 751
  • 1
  • 14
  • 34
  • 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. – Chris Apr 11 '16 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? – user1491987 Apr 11 '16 at 18:35
  • That does seem odd. I would go ahead and enable it. – Chris Apr 11 '16 at 18:56

2 Answers2

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.

user1491987
  • 751
  • 1
  • 14
  • 34
3

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

jhovgaard
  • 560
  • 4
  • 18