Node trusted connection using msnodesqlv8

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);
    // 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 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.

+4
source share
2 answers

Read the documentation; there is no such function.

sql.open().

+3

MySQL, Sequelizejs, doccumnetation , MSSQl, msnodesqlv8, sql.open(connStr, callback(err, conn)). .

, MySQL MSSQL . Sequelizejs MSSQL.

+2

Source: https://habr.com/ru/post/1688304/


All Articles