Hey there fellow coders! I've been facing an issue while trying to make a database query using the odbc package found at https://www.npmjs.com/package/odbc. Interestingly, I can successfully run queries using FlySpeed SQL Query. However, when attempting to query through the package, I encounter the following error:
[Error: [odbc] Error preparing for fetch] {
odbcErrors: [
{
state: 'HYC00',
code: 0,
message: "[Transoft][TSODBC][usqlsd]SQLSetStmtOption Option '5' is not supported "
}
]
}
Below is the snippet of my controller (From an adonisjs v4 API):
"use strict";
const odbc = require("odbc");
class OdbcController {
async fetchData() {
odbc.connect('DSN=triad.udd;', (error, connection) => {
if (error) {
console.log(error)
}
let sql = "Select Customer From m.POS_ARC_D_HEAD;"
connection.query(sql, (error, result) => {
if (error) {
console.log(error)
}
console.log('result', result)
})
});
}
}
module.exports = OdbcController;
I have managed to establish a connection to the database. Interestingly, when I purposely misspell the table name, it correctly informs me that the table does not exist. However, upon querying an existing table, I receive the aforementioned error as well as this additional error (my application crashes after about 3 seconds with this log message):
/c/Program Files (x86)/nodejs/npm: line 44: 1226 Segmentation fault "$NODE_EXE" "$NPM_CLI_JS" "$@"
You can find the documentation for the odbc driver here (I believe):
If anyone has any insights on how to resolve this issue, I would greatly appreciate your help. Thank you in advance!
Note that both the Transoft ODBC Driver and my Node.js are in 32-bit versions to prevent compatibility issues.