1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Node trusted connection using msnodesqlv8

Discussão em 'Outras Linguagens' iniciado por Stack, Julho 8, 2021.

  1. Stack

    Stack Membro Participativo

    I'm trying to connect to SQL server using msnodesqlv8 driver. Now I'm getting an error (TypeError: sql.connect is not a function) before I try to connect with msql driver and I got response but I really need to use a trusted connection. my code:

    var express = require('express');
    var app = express();

    app.get('/', function (req, res) {

    var sql = require("msnodesqlv8");
    // config for your database
    var config = {
    server: 'sqlServername',
    database: 'myTestDatabase',
    driver: "msnodesqlv8",
    options: {
    trustedConnection: true

    // connect to your database
    sql.connect(config, function (err) {

    if (err) console.log(err);

    // create Request object
    var request = new sql.Request();

    // query to the database and get the records
    request.query('select * from myTable', function (err, recordset) {

    if (err) console.log(err)

    // send records as a response


    var server = app.listen(5000, function () {
    console.log('Server is running..');

    Is there any other driver I can use trusted connection? I'm using sql server 12.0.4237.0

    I try this as well

    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

    .then(conn => console.log("Success!"))
    .catch(err => console.log("error! " + err));

    I receive this error:

    ConnectionError: [Microsoft][SQL Server Native Client 11.0][SQL Server]Login failed for user 'domainxxx\userxxxx'.

    Continue reading...

Compartilhe esta Página

Para os pais de Plantão algumas dicas