I am trying to connect to an Access database with nuintun's node-adodb package. I have successfully connected to it in my laptop @ home and created a dist. package to install it to my computer @ office. However after installing it to my office laptop, I am getting below error message during connection to access database.
connection string:
"Provider=Microsoft.ACE.OLEDB.12.0;User ID=Admin;Data Source=C:\\Temp\\Mdb.mdb;Persist Security Info=False;"
error message:
Error: Spawn C:\WINDOWS\SysWOW64\cscript.exe error
I tried several connection configs to solve this but cannot get it done.
With this method (connection = ADODB.open(dbConn);) I am getting above error message.
With this connection = ADODB.open(dbConn, true) or this connection=ADODB.open(process.arch.includes('64') or this connection = ADODB.open(connection, 'x64') I am getting below error message:
Error: Spawn C:\WINDOWS\System32\cscript.exe error
Any help appreciated.
You can try installing MS Access Database Engine and then call it from your code via
Provider=Microsoft.ACE.OLEDB.16.0 (.....)
https://www.microsoft.com/en-us/download/details.aspx?id=54920. It helped me with the same issue you are facing now.
@Ozgun Senyuva, one more thing... because after packaging I spotted one more issue that was solved as per https://github.com/nuintun/node-adodb/blob/master/README-EN.md
Electron
If you want to use this module in an electron app running from an asar package you'll need to make some changes.
Move adodb.js outside the asar package (in this example I use electron-builder, the extraResources option can move the file outside the asar package)
"extraResources": [
{
"from": "./node_modules/node-adodb/lib/adodb.js",
"to": "adodb.js"
}
]
Tell the module where to find adodb.js while running from an asar package (I added this in electron's main.js file)
// Are we running from inside an asar package ?
if (process.mainModule.filename.indexOf('app.asar') !== -1) {
// In that case we need to set the correct path to adodb.js
ADODB.PATH = './resources/adodb.js';
}
Works like a charm now!