PopGoesTheWza
PopGoesTheWza

Reputation: 618

Can't make sense why ConnectionError: Data source name not found and no default driver specified

I need to process data from an internal SQL Server database using NodeJs (version 20.*). Connection to the database has to use Windows Authentication, thus I opted for the Tedious mssql and the msnodesqlv8 packages, since Tedious alone does not support it.

The minimal functioning Typescript code to get a connection pool is

import mssql, {type config as Config} from 'mssql/msnodesqlv8';

const baseConfig: Partial<Config> = {
  database: 'XX',
  options: {
    trustedConnection: true,
  },
};

export const getPool = async () => {
  const server = `xxxx01.subdom.dom.priv`;

  const p = new mssql.ConnectionPool({...baseConfig, server});
  await p.connect();

  return p;
};

The above code works fine from my Mac Book Pro workstation with ODBC Driver 17 for SQL Server installed.

But when executed on a Windows 2019 Server, it fails with an error

ConnectionError: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

Yet on that very Windows server I was able to

I have tried many variations of the above code (as connection strings, specifying driver, instance, adding the port number without success or even some change in the error message.

I tried to use tracing from the ODBC Data Source Administrator but can't make much sense out of it

Please advise

Upvotes: 1

Views: 84

Answers (0)

Related Questions