How to connect to SQL Server with windows authentication from Node.JS using mssql module

前端 未结 12 1390
忘掉有多难
忘掉有多难 2020-11-27 13:57

Hi I\'m unable to connect to SQL server that is using windows authentication in node js. I\'m using the mssql module. The error message is :

[ConnectionError         


        
12条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-27 14:27

    For me

    I used connection setting as below

    "server":"",
    "domain":"", //sepcify domain of your user 
    "port": ,
    "user":"", // enter username without domain
    "password":"",
    "database":""
    

    and the TS code

    import * as sql from 'mssql';
    
    const pool = await new sql.ConnectionPool(connection).connect();
    const result = await pool.request()
                .query(`SELECT count(idpart) part_computed FROM demo.PARTs;`);
    pool.close();
    return Promise.resolve(result.recordset);
    

提交回复
热议问题