0

I need to open an access database, who is located in the server, using javascript. I tried with this code:

var connection = new ActiveXObject("ADODB.Connection") ;
var connectionstring="Data Source=<server>;Initial Catalog=<catalog>;User ID=<user>;Password=<password>;Provider=SQLOLEDB";

connection.Open(connectionstring);
var rs = new ActiveXObject("ADODB.Recordset");

rs.Open("SELECT * FROM table", connection);

.... but the debug return this error:

ReferenceError: ActiveXObject is not defined

how I can load the ActiveXObject for ADODB.Connection and define it?

Alfabravo
  • 7,232
  • 6
  • 43
  • 77
Dregi
  • 11
  • 2
  • `ActiveXObject` is only available in Internet Explorer. – J. Titus Mar 15 '17 at 23:03
  • Possible duplicate of [ActiveXObject is not defined and can't find variable: ActiveXObject](http://stackoverflow.com/questions/11101641/activexobject-is-not-defined-and-cant-find-variable-activexobject) – J. Titus Mar 15 '17 at 23:03

1 Answers1

1

ActiveX is deprecated.

https://blogs.windows.com/msedgedev/2015/05/06/a-break-from-the-past-part-2-saying-goodbye-to-activex-vbscript-attachevent/

If you want to use Javascript to establish a connection to your database - You could use fx Node.js

Webbanditten
  • 794
  • 8
  • 19
  • But Node.js he is able to open an access database? – Dregi Mar 15 '17 at 23:14
  • Yes indeed it is. I don't know what your thoughts or reason was to use ActiveX, but regard less. Usually if we are talking a website that needs access to a database, you would make your backend connect to your database. However it is possible to do desktop applications in node.js if you want to stick with javascript. Either way if you want more help you need to provide us with more information around your project. Im just assuming here that you want to do it in javascript, hence your question. – Webbanditten Mar 15 '17 at 23:19
  • In the web there are many guides that say how Node can be used in LOCAL pc too; so many guides explain how install it in windows. Good. I wouldn't use Node in local. If I want use Node ONLINE how can I install it in a windows-web-server? I have this need because i must open, from a web page, an access database online, without installing nothing in the client. Is it possible? Others solution for javascript? – Dregi Mar 16 '17 at 17:00
  • Hi Dregi, its seems like your not that strong of a developers yet. I would recommend you to look at some tutorial on how to create a backend for a website. As I understand it, you want to host an application on a Windows server that simply connects to a database - Since its on a Windows server I recommend you take a look at IIS https://www.iis.net/ and get familiar with C# and the ASP.NET platform: https://www.asp.net/ Tutorial: https://www.tutorialspoint.com/asp.net/ – Webbanditten Mar 16 '17 at 18:42
  • Hi, I am not a professional developer of course :), I like develope software only for hobby....my hair are grey (lol) :) In reality I want easy connect an access database online and pass the value read from database to a variable in javascript. I know the difficulty to make it, because of running server-side and client-side, for this reason I would open the database from javascript. – Dregi Mar 16 '17 at 19:50
  • Then I think you should install Internet explore 6, and use ActiveX. Good luck. – Webbanditten Mar 17 '17 at 08:13
  • This way solves my problem: from javascript I use OpenWindow that open a asp-page and passes a variable with a name to find. The asp-page is linked to database and reads a value from this one and writes a cookie with this value. From initial page javascript reads the cookie. Solved – Dregi Mar 18 '17 at 07:42