1

I have to connect with mssql database using window authentication where I am using Nodejs and msnodesqlv8. I followed How to connect to SQL Server with windows authentication from Node.JS using mssql module to do the setup code but as it's window authentication so no username/password required but after writing code connection using above link

const sql = require("mssql/msnodesqlv8");
const conn = new sql.ConnectionPool({
  database: "db_name",
  server: "server_name",
  driver: "msnodesqlv8",
  options: {
    trustedConnection: true
  }
});
conn.connect().then(() => {
  // ... sproc call, error catching, etc
  // example: https://github.com/patriksimek/node-mssql#request
});

I am getting this error ConnectionError: Login failed for user '', I tried a lot of links to understand the root cause but I am unable to understand also I am working on Mac M1, Azure data studio where manually I am not able to connect to database using window authentication as I am getting error 'Connection failed due to Kerberos error' so is this the cause, please help me to understand the issue.

3
  • Is your computer joined to an Active Directory (or Kerberos) domain? Commented Aug 22, 2022 at 8:40
  • Are you sure the credentials like port, host , db name etc. info are correct? Commented Aug 22, 2022 at 9:26
  • 1
    yes, I changed my machine to window's const connectionString = "server=W70100\\SQLEXPRESS01.;Database=Test;Trusted_Connection=Yes;Driver={SQL Server Native Client 11.0}"; sql.query(connectionString, "SELECT * from Emp", (err, rows) => { if (err) console.log('Database Connection Failed! godd: ',err); console.log(rows); }); error I am getting [Error: [Microsoft][SQL Server Native Client 11.0]The client cannot connect to the server because the requested instance was not available. Use SQL Server Configuration Manager to make sure the SQL Server instance is configured correctly. Commented Aug 23, 2022 at 10:47

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.