{"id":16325,"library":"database-js-adodb","title":"Database-js Wrapper for ADODB","description":"Database-js-adodb is a wrapper library designed to provide ADO (ActiveX Data Objects) connectivity for JavaScript applications, specifically integrating with the database-js abstraction layer. Currently at version 1.1.3, this package offers a standardized interface for interacting with various Microsoft data sources like Access and Excel, leveraging the underlying `node-adodb` package. Its primary differentiator is enabling ADO access within a Node.js environment, particularly useful for legacy Windows-based data systems. A key limitation is its strict dependency on Windows operating systems, as it relies on the Windows Script `cscript` for ADO operations. While it can be used standalone to leverage Promises with ADO, its main purpose is to extend `database-js` with ADO support. Release cadence is typically tied to updates in its upstream dependencies or bug fixes rather than frequent feature additions.","status":"maintenance","version":"1.1.3","language":"javascript","source_language":"en","source_url":"https://github.com/mlaanderson/database-js-adodb","tags":["javascript","database-js","adodb","sql","access","microsoft adodb"],"install":[{"cmd":"npm install database-js-adodb","lang":"bash","label":"npm"},{"cmd":"yarn add database-js-adodb","lang":"bash","label":"yarn"},{"cmd":"pnpm add database-js-adodb","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core ADODB functionality","package":"node-adodb","optional":false},{"reason":"Primary integration target for database abstraction, providing a unified API for various drivers.","package":"database-js2","optional":true}],"imports":[{"note":"This package is CommonJS-only, requiring `require()`. When imported this way, `adodb` refers to the `ADODBConnection` class constructor for standalone use.","wrong":"import adodb from 'database-js-adodb';","symbol":"adodb","correct":"const adodb = require('database-js-adodb');"},{"note":"The package's main export is the `ADODBConnection` class. While you can destructure it, it's more common to assign the module export to a variable like `adodb` and instantiate from there (e.g., `new adodb(connectionString)`).","wrong":"import { ADODBConnection } from 'database-js-adodb';","symbol":"ADODBConnection","correct":"const { ADODBConnection } = require('database-js-adodb'); const connection = new ADODBConnection(connectionString);"},{"note":"For the primary integrated usage pattern, you will also need to import the `Database` class from `database-js2`. This package is also CommonJS-only and requires `require()`.","wrong":"import Database from 'database-js2';","symbol":"Database","correct":"const Database = require('database-js2');"}],"quickstart":{"code":"const Database = require('database-js2'); // database-js2 is a peer dependency for primary use case\n\n(async () => {\n    let connection, statement, rows;\n    const dbPath = process.env.DB_PATH || 'C:\\\\Users\\\\me\\\\Desktop\\\\access_db.mdb'; // Example path, adjust as needed\n    const connectionString = `database-js-adodb:///${dbPath}`;\n\n    try {\n        // Connect to the ADODB source via database-js\n        connection = new Database(connectionString);\n        \n        // Prepare and execute a parameterized query\n        statement = await connection.prepareStatement(\"SELECT * FROM tablea WHERE user_name = ?\");\n        rows = await statement.query('not_so_secret_user');\n        console.log(\"Query Results for Access DB:\", rows);\n\n        // Example for Excel (version 8) connection\n        const excelPath = process.env.EXCEL_PATH || 'C:\\\\Users\\\\me\\\\Desktop\\\\excel_file.xls'; // Example path, adjust as needed\n        // Note: Extended Properties must be correctly escaped within the connection string\n        const excelConnectionString = `database-js-adodb:///${excelPath}?Extended Properties='Excel 8.0;HDR=Yes;IMEX=1';`;\n        const excelConnection = new Database(excelConnectionString);\n        const excelStatement = await excelConnection.prepareStatement(\"SELECT * FROM [Sheet1$A1:C52] WHERE user_name = ?\");\n        const excelRows = await excelStatement.query('another_user');\n        console.log(\"Excel Query Results:\", excelRows);\n        await excelConnection.close();\n\n    } catch (error) {\n        console.error(\"An error occurred:\", error);\n    } finally {\n        if (connection) {\n            await connection.close();\n        }\n    }\n})();","lang":"javascript","description":"Demonstrates connecting to both an Access database and an Excel spreadsheet using `database-js-adodb` through the `database-js2` abstraction layer, performing parameterized queries, and closing connections."},"warnings":[{"fix":"Ensure the application using `database-js-adodb` is deployed and executed exclusively on a Windows operating system. Consider alternative database drivers or architectures for cross-platform requirements.","message":"This package is strictly Windows-only. It relies on ActiveX Data Objects (ADO) and the Windows Script Host (`cscript`) for its functionality, meaning it will not run on Linux, macOS, or other non-Windows environments.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Migrate your project to use CommonJS `require()` statements for `database-js-adodb` and `database-js2`, or use a bundler (like Webpack or Rollup) configured to handle CommonJS modules within an ESM project.","message":"The package is CommonJS-only, meaning it uses `require()` for module imports. Attempting to use ES module `import` syntax will result in errors.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Carefully construct the 'Extended Properties' within your connection string based on your Excel file's format and requirements. Consult Microsoft ADO documentation for specific property values. Ensure proper escaping of quotes within the connection string.","message":"When using `database-js-adodb` with Excel files, the connection string's 'Extended Properties' (e.g., `'Excel 8.0;HDR=Yes;IMEX=1;'`) are crucial for correct parsing and data interpretation. These properties vary based on Excel version and desired behavior (e.g., header row, mixed data types).","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-22T00:00:00.000Z","next_check":"2026-07-21T00:00:00.000Z","problems":[{"fix":"When using `database-js-adodb` in standalone mode, instantiate a new connection object directly: `const adodb = require('database-js-adodb'); const connection = new adodb(connectionString);` (or `new adodb.ADODBConnection(connectionString)`).","cause":"The standalone example in the README contains a typo, erroneously referencing `mysql.open` instead of the correct `database-js-adodb` connection method.","error":"TypeError: mysql.open is not a function"},{"fix":"Install `database-js2` explicitly: `npm install database-js2`.","cause":"`database-js2` is a peer dependency for the primary integration use case but is not automatically installed with `database-js-adodb`.","error":"Error: Cannot find module 'database-js2'"},{"fix":"Ensure the correct Microsoft Access Database Engine Redistributable (or Office components) matching the bitness of your Node.js process and desired database file type is installed on the Windows machine. For older Access `.mdb` files, `Microsoft.Jet.OLEDB.4.0` is usually sufficient; for newer `.accdb` and Excel files, `Microsoft.ACE.OLEDB.12.0` or later is needed.","cause":"The necessary ADO provider (e.g., Microsoft.Jet.OLEDB.4.0 for Access .mdb, or Microsoft.ACE.OLEDB.12.0 for .accdb and newer Excel) is not installed or correctly configured on the Windows system. This often occurs on 64-bit systems trying to use a 32-bit provider, or missing redistributables.","error":"Error: [ADODB] Provider cannot be found. It may not be properly installed."}],"ecosystem":"npm"}