nuintun/node-adodb

Can't get it to work with .mdb files

isrhedden opened this issue · 0 comments

My application works perfectly fine with .accdb Access files but 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 with both .mdb and .accdb, so I'm guessing that it's something to do with how my container environment is set up.

Below is the code for my base Dockerfile:

# 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 32bit Access Driver
ADD https://download.microsoft.com/download/2/4/3/24375141-E08D-4803-AB0E-10F2E3A07AAA/AccessDatabaseEngine.exe AccessDatabaseEngine.exe
RUN powershell -Command "Start-Process -NoNewWindow -FilePath \"AccessDatabaseEngine.exe\""

# Download and install Node.js
ADD https://nodejs.org/dist/v12.9.1/node-v12.9.1-x64.msi node.msi
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 vars depending on if it's a .accdb .mdb file
  const fileExt = file.path.split('.').pop();
  const connStrAccdb = `Provider=Microsoft.ACE.OLEDB.12.0;Data Source=${file.path};Persist Security Info=False;`; // This fails
  const connStrMdb = `Provider=Microsoft.Jet.OLEDB.4.0;Data Source=${file.path};`; // This works
  const connStr = fileExt === "accdb" ? connStrAccdb : connStrMdb;

  // Initialize export connection depending on if we are local or live
  let access;
  const use64 = process.env.NODE_ENV === "development" ? true : false;
  if (use64) {
      access = ADODB.open(connStr, use64);
  } else {
      access = ADODB.open(connStr);
  }

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.