jasper jasper - 1 year ago 218
Node.js Question

connect to sql server with node.js

hey I want to connect to SQL server using node.js can any one tell me the way how can I do that.

My work: i have searched few npm modules(node-sqlserver) but that dosent work for me much any help will really he appreciated.

Answer Source

hey You can do this by using npm module called seriate. You need to install this module

npm install --save seriate

var sql = require("seriate");

var config = {
    user: 'userName',
    password: 'password',
    server: 'serverIp',
    database: 'dataBaseName'

sql.setDefaultConfig( config );

sql.execute( {
  query:'select * from tableName '//By using this query you can search the the data in the table
  query:"insert into tableName (name,age,address,contactNo) VALUES ('shumi',23,'India',3838388)" // you can insert data using this query

} ).then( function( results ) {
    console.log( results );
}, function( err ) {
    console.log( "Something bad happened:", err );
} );

for more details you can even visit http://developer.leankit.com/painless-sql-server-with-nodejs-and-seriate/

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download