-1
我想連接到MS SQL數據庫使用節點JS但我收到以下錯誤。Nodejs連接SQL沒有連接
{ ConnectionError: Login failed for user 'Gurpanth'. at ConnectionError not connected
var express = require('express');
var router = express.Router();
/* GET home page. */
router.get('/', function(req, res, next) {
GetData(function (recordSet) {
res.render('index', {product: recordSet})
});
});
var Connection = require('tedious').Connection;
var config = {
userName: "Gurpanth",
password: "windowspassword",
server: "GURPANTH",
options: {
database: "NodeJSDb",
encrypt: true,
}
};
var connection = new Connection (config);
connection.on('connect', function(err){
console.log(err);
if(err!=null){
console.log("not connected");
}
else{
console.log("Connected")
connection.close();
};
});
module.exports = router;