Cannot connect no matter what. No error message either
const sql = require('mssql/msnodesqlv8');
(async () => {
try {
await sql.connect("Driver={SQL Server Native Client 11.0};Server=localhost\\SQLEXPRESS;Database=MyDB");
const result = await sql.query`select TOP 10 * from MyTable`;
console.dir(result);
} catch (err) {
console.error(err);
}
})();
Error:
D:\testt>node main.js
ConnectionError: [object Object]
at PrivateConnection.callback2 (D:\testt\node_modules\mssql\lib\msnodesqlv8\connection-pool.js:46:17)
at Immediate.<anonymous> (D:\testt\node_modules\msnodesqlv8\lib\connection.js:47:14)
at process.processImmediate (node:internal/timers:485:21) {
code: undefined
}
The worst part is the code: undefined. There is nothing I can do to debug this. Using the alternative library: https://www.npmjs.com/package/msnodesqlv8 I can connect using ODBC driver and it connects just fine. But for this library it will not connect no matter what I do. There is no error message either
Please provide the versions of the packages you are using.
You should be able to attach a debugger and debug this, just because the underlying error doesn't expose a code doesn't prevent this from being debugged.
~~Fixed in https://github.com/tediousjs/node-mssql/commit/a82be0ca33d1715d61e0250d0958b4da138c253a~~ Update to v12.1.1 to get more information
thanks @alexsch01 but I'm not sure that presenting the error actually fixes the issue of "cannot connect...", it simply surfaces and error that could be collected by attaching a debugger.