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

  2. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

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");
    console.log(sql);
    // 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
    res.send(recordset);

    });
    });
    });

    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
    }
    }


    sql.connect(config)
    .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