Mohammed Saber
Mohammed Saber

Reputation: 171

How to retrieve all columns in a MS Access database using ADODB [Node JS]

I normally use Select COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'Table Name' to retrieve all columns in a SQL database but how can I do the same using ADODB for an access database?

Upvotes: 0

Views: 220

Answers (1)

Mohammed Saber
Mohammed Saber

Reputation: 171

There is no method to get the columns of a table from MS Access as far as I know so how I went about it was by selecting the first row in the table and then splitting it's keys. This gives me an array of the columns.

const Query = "SELECT Top 1 * FROM "+req.body.table
  const connection = adodb.open(cn);
  try {
    connection
    .query(Query)
    .then((data) => {
     res.json(Object.keys(data[0]))
    })

Upvotes: 1

Related Questions