0

I am accessing an MS Access DB using JavaScript:

var conn = new ActiveXObject("ADODB.Connection");
conn.open("Provider=Microsoft.ACE.OLEDB.12.0;Data Source="C:/Myfile.accdb";Persist Security Info=False", "", "");

var rs = new ActiveXObject("ADODB.Recordset");
rs.open("SELECT * FROM MyTable", conn, 2, 3);

One of the columns is an attachment field, containing one or more images. How can I access those images and display them in a web browser?

If it was a text field, I would simply use

rs.Fields(x).Value

But this seems not to work with files.

Simon
  • 326
  • 1
  • 12
  • 1
    Would have to extract image files to folder location. https://stackoverflow.com/questions/37595786/ms-access-vba-trying-to-extract-each-file-in-a-tables-attachments-to-disk. Many experienced developers will not use Attachment field, just save file path to text field. – June7 Aug 01 '19 at 18:17
  • I know and I normally wouldn't save a file to a database like this. However, in this case it's simply more convenient to store the images in the database. Is there some function (like TO_BASE64 in MySQL) in MS Access SQL that allows to base64 encode the binary data? In this case I could simply add the base64 encoded images to the html body. – Simon Aug 01 '19 at 22:37
  • And how do I save the files in JavaScript? The example you mentioned above is in ASP and I wasn't able to find any documentation for JavaScript. – Simon Aug 02 '19 at 08:02
  • The example I referenced is VBA, not ASP. I have no idea how to do in JavaScript. – June7 Aug 02 '19 at 08:31
  • The example referenced as duplicate solution looks like JavaScript to me. – June7 Aug 03 '19 at 03:03
  • It's not JavaScript, but VB Script. – Simon Aug 04 '19 at 08:58
  • Between the two links referenced, I think code examples are JavaScript, VB.net, and VBA. I have used VBScript and it looks like VBA. – June7 Aug 04 '19 at 11:28
  • But it's certainly not JavaScript :) – Simon Aug 04 '19 at 11:40
  • Then maybe Java or C#. – June7 Aug 04 '19 at 11:58

0 Answers0