1

I want to connect to SqlServer through Node.js.

I have tried many ways and many links but nothing is work properly. I want to connect to SqlServer and fetch some data.

Please can someone suggest some steps and code to connect SqlServer 2008. What is the Driver for Sql-Node.js?

1
  • i m using OS windows 7 with 64 bit processor. plz suggest some ans.... Commented Jun 18, 2013 at 11:26

1 Answer 1

1

I just did it following this walkthrough at http://tech.pro/tutorial/1848/getting-nodejs--sql-server--azure-to-work-together

He's using the "msnodesql" package at https://www.npmjs.org/package/msnodesql, code at git-hub at https://github.com/WindowsAzure/node-sqlserver, and I've got it running in a node-console app with a simple select-statement:

var mssql = require('msnodesql');

var conn_str = "Driver={SQL Server Native Client 10.0};Server=tcp:xxxxx;Database=yyyy;Uid=zzzz;Pwd=wwww;Connection Timeout=30;";

    mssql.query(conn_str, "select * from testtable", function(err, recordset) {
    if(err){
        console.log("Got error :-( " + err);
        return;
    }

    recordset.forEach(function(record) {
        console.log("name: " + record.Name + " (" + record.ID + ")");

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

Comments

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.