connect to sql server 2012 with node.js

[亡魂溺海] 提交于 2019-12-11 23:50:43

问题


I want to connect a sql db with node, so i find this npm package https://www.npmjs.com/package/mssql

I'am looking forward to create a simple authentication so for a start i just want to connect to the sql db, so my problem is when i tried to execute the existing code in mssql documentation i get an error here is what i executed :

   var sql = require('mssql');

   var config = {

   user: '...',   
    password: '...',
   server: 'localhost', 
    database: 'dbUsers'
    }

    sql.connect(config, function(err) {

     throw err; // error checks

     var request = new sql.Request();
      request.query('select * from tblUsers'); 

      request.on('recordset', function(columns) {
    // Emitted once for each recordset in a query
        console.log(columns);
       });

       request.on('row', function(row) {
       console.log (row);
     });



  });

来源:https://stackoverflow.com/questions/28474096/connect-to-sql-server-2012-with-node-js

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!