Reputation: 35
I am attempting to write a containerized Node application on Windows OS that intakes Microsoft Access databases and accesses the data within. I wish to use npm node-adodb to interact with Access.
My application works perfectly fine with .accdb Access files. When I try to connect to .mdb Access files I get this error Spawn C:\Windows\SysWOW64\cscript.exe error, Provider cannot be found. It may not be properly installed
. My code works on my local Windows computer, so I'm guessing that it's something to do with how my container environment is set up.
I set up the base Dockerfile like this:
# Get base Windows OS image
FROM mcr.microsoft.com/windows/servercore:ltsc2019
# Set environment variables
ENV NPM_CONFIG_LOGLEVEL info
ENV NODEJS_VERSION 12.9.1
# Download & Install 2010 Access Driver
RUN powershell -Command "wget -Uri https://download.microsoft.com/download/2/4/3/24375141-E08D-4803-AB0E-10F2E3A07AAA/AccessDatabaseEngine.exe -OutFile AccessDatabaseEngine.exe -UseBasicParsing"
RUN powershell -Command "Start-Process -NoNewWindow -FilePath \"AccessDatabaseEngine.exe\""
# Download & Install 2016 Access Driver
RUN powershell -Command "wget -Uri https://download.microsoft.com/download/3/5/C/35C84C36-661A-44E6-9324-8786B8DBE231/accessdatabaseengine_X64.exe -OutFile accessdatabaseengine_X64.exe -UseBasicParsing"
RUN powershell -Command "Start-Process -NoNewWindow -FilePath \"accessdatabaseengine_X64.exe\""
# Download and install Node.js
RUN powershell -Command "wget -Uri https://nodejs.org/dist/v%NODEJS_VERSION%/node-v%NODEJS_VERSION%-x64.msi -OutFile node.msi -UseBasicParsing"
RUN msiexec.exe /q /i node.msi
# Run node
CMD [ "node" ]
I establish the Access connection like so. How I instantiate the connection differs depending on if I'm in my local environment or online. It also differs on .accdb vs .mdb:
// Define connection string & initialize export connection depending on if it's a .accdb .mdb file
let access;
if ((file.path).substring(Math.max(0, (file.path).toString().length - 5)) === 'accdb') {
const connStr = `Provider=Microsoft.ACE.OLEDB.12.0;Data Source=${file.path};Persist Security Info=False;`;
access = ADODB.open(connStr); // This works
} else {
const connStr = `Provider=Microsoft.Jet.OLEDB.4.0;Data Source=${file.path};`;
access = ADODB.open(connStr); // This fails
}
Is there another software package that I need to install in order to work with .mdb files? Do I need to connect in a different way? Any help would be very much appreciated.
Upvotes: 1
Views: 1717
Reputation: 115
With the error message coming from "C:\Windows\SysWOW64\cscript.exe", please make sure that you have the 32-bit version of the "Microsoft Access Database Engine" distribution package installed.
If you have the 64-bit engine package installed, open the database connection like this:
access = ADODB.open(connStr, true);
Upvotes: 1