nuintun / node-adodb

A node.js javascript client implementing the ADODB protocol on windows.
https://nuintun.github.io/node-adodb
MIT License
185 stars 51 forks source link

node.js with MSAccess #64

Closed ruicoutobmarques closed 6 years ago

ruicoutobmarques commented 6 years ago

Hi nuintun, i need your help if possible. I have a little code to work on a MSAccess database. This is the code to SELECT statement:

const ADODB = require('node-adodb');

ADODB.debug = true;

const connection = ADODB.open('Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Node.js\\BD\\MyDB.mdb;');

var query = 'SELECT * FROM table1;'

connection

    .query(query)
    .then(data => {
        res.send( data );
    })
    .catch(error => {
        res.send( error );
    });

The result is good, no errors.

If i change the query:

'SELECT * FROM table1;'

by this:

'DELETE * FROM table1;'

The query is executed, the registrys are deletede, but a receive the following error:

{ Error: Spawn C:\WINDOWS\SysWOW64\cscript.exe error at ChildProcess.child.on.exitCode (D:\MARQUES\Node.js\PROJETOS\GESTWS\node_modules\node-adodb\lib\spawn.js:120:37) at emitTwo (events.js:126:13) at ChildProcess.emit (events.js:214:7) at maybeClose (internal/child_process.js:925:16) at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5) process: { code: -2146824584, message: 'Operation is not allowed when the object is closed.' }, exitCode: 0 }

Do you have any idea what is wrong? Thank you Rui

ruicoutobmarques commented 6 years ago

Hi again, Looking your examples, I found the solution. Is very simple. I was using

connection .query(query)

The correct way is:

connection .execute(query)

Regards Rui