I am trying to connect to a SQL server using msnodesqlv8 driver. Now I get an error (TypeError: sql.connect is not a function) before trying to connect to the msql driver, and I got a response, but I really need to use a trusted connection. my code is:
var express = require('express');
var app = express();
app.get('/', function (req, res) {
var sql = require("msnodesqlv8");
console.log(sql);
var config = {
server: 'sqlServername',
database: 'myTestDatabase',
driver: "msnodesqlv8",
options: {
trustedConnection: true
}
};
sql.connect(config, function (err) {
if (err) console.log(err);
var request = new sql.Request();
request.query('select * from myTable', function (err, recordset) {
if (err) console.log(err)
res.send(recordset);
});
});
});
var server = app.listen(5000, function () {
console.log('Server is running..');
});
Is there any other driver with which I can use a reliable connection? I am using SQL Server 12.0.4237.0
I also try to do it.
const sql = require('mssql/msnodesqlv8');
const config = {
user: "xxxxxxxx",
password: "xxxxxxxxx",
domain: "xxxxxxx.com",
server: 'hubuddb66',
database: 'KSheduler',
pool: {
max: 10,
min: 0,
idleTimeoutMillis: 30000
},
options: {
trustedConnection: true
}
}
sql.connect(config)
.then(conn => console.log("Success!"))
.catch(err => console.log("error! " + err));
I get this error:
ConnectionError: [Microsoft] [Native SQL Server 11.0 Client] [SQL Server] Error logging on to user domain domainxxx \ userxxxx.
source
share