3

I am trying to connect to SQL Server on my local machine. I am trying to use tedious and tedious-ntlm. The configuration for both is as below:

var tds = require("tedious-ntlm");
//var tds = require("tedious");
var config = {
userName: 'pratikdb',
password: 'pratikdb',
server: '.',
options: {
    database: "TEST",
    debug: {
        packet: false,
        payload: false,
        token: false,
        data: false
    },
    encrypt: true
  }
};


http.createServer(app).listen(app.get('port'), function () {
    console.log('Express server listening on port ' + app.get('port'));
    var connection = new tds.Connection(config);
    connection.on('connect', function (err) {
        console.log(err);
    });
});

When I am working with tedious, I am getting this error:

ConnectionError: Failed to connect to .:1433 - getaddrinfo ENOTFOUND . .:1433]
message: 'Failed to connect to .:1433 - getaddrinfo ENOTFOUND . .:1433', code: 'ESOCKET'

When I am working with "tedious-ntlm", I am getting this error:

Connection to .:1433 - failed Error: getaddrinfo ENOTFOUND . .:1433

As mentioned here, I tried using ip of machine even then I am getting same error.

Edit:

When I modified the config as below as per suggestion by @jmugz3:

var config = {
    userName: 'pratikdb',
    password: 'pratikdb',
    server: 'DELL',
    options: {
        instanceName: ".",
        database: "TEST",
        debug: {
            packet: false,
            payload: false,
            token: false,
            data: false
        },
        encrypt: true
    }
};

I am getting error :

Error: Port for . not found in ServerName;DELL;InstanceName;MSSQLSERVER;IsClustered;No;Version;11.0.2100.60;tcp;1433;np;\DELL\pipe\sql\query;;

Can anyone please help me?

Thanks in advance.

4
  • Have you tried using the actual server name rather than (.) for localhost? Commented Mar 13, 2016 at 6:31
  • @jmugz3 I tried with MSSQLServer, if that is correct. If not, can you point me how to find the server name? With MSSQLServer, I am getting same errors. Commented Mar 13, 2016 at 6:35
  • try SELECT @@SERVERNAME after you login in your instance of sql server. Commented Mar 13, 2016 at 6:37
  • @jmugz3, please see the edit I made to the question. I am getting below error after adding instancename: Error: Port for . not found in ServerName;DELL;InstanceName;MSSQLSERVER;IsClustered;No;Version;11.0.2100.60;tcp;1433;np;\\DELL\pipe\sql\query;; Without instance name all I am getting is "Undefined" Commented Mar 13, 2016 at 6:46

1 Answer 1

5

Found an answer tedious discussion. Changed my configuration variable to

var sqlConfig = {
    userName: 'pratikdb', //username created from SQL Management Studio
    password: 'pratikdb',
    server: 'DELL',    //the IP of the machine where SQL Server runs

    options: {
        instanceName: 'MSSQLSERVER',
        database: 'Test',  //the username above should have granted permissions in order to access this DB.
        debug: {
            packet: false,
            payload: false,
            token: false,
            data: false
        },
        //encrypt: true
    }

};

the main points were to look for were uppercasing of server and instanceName. for some reason tedious is maintaining case-sensitivity in both key and value of array.

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

2 Comments

@sqluser you are right. There was issue in connectivity when i was posting this answer. I will update the answer soon as come back online.
Commenting out // encrypt: true worked for now. But I guess it's better to have encrypt=true if I can find a solution to make it work.

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.