Q:

Connecting to a MySQL Database and do a query using only client side Javascript and HTA

In a HTA application, how to connect to a MySQL database using JavaScript ONLY and do a query in it? No VBScript and no third parties like node.js, just JavaScript.

A:

A HUGE thanks to Kul-Tigin for providing the answer for the USE of ADO ActiveX which I did not even think about. I was not searching properly the ODBC connection methods and always fell on VBScript. So here is a working code of a personal test I did after installing the latest MySQL ODBC Connector as of the date of this comment.
var hmess = document.getElementById("mess");
var oconn = new ActiveXObject("ADODB.Connection");
var ors = new ActiveXObject("ADODB.Recordset");
var sconn = "";
var scn_driver = "DRIVER=MySQL ODBC 8.0 Unicode Driver;";
var scn_server = "SERVER=localhost;";
var scn_database = "DATABASE=DatabaseName;";
var scn_userid = "USER ID=UserName;";
var scn_password = "PASSWORD=UserPassword;";
var ssql = "SELECT * FROM Table WHERE IDField=1";

sconn = scn_driver + scn_server + scn_database + scn_userid + scn_password;

oconn.Open(sconn);
ors.Open(ssql,oconn);
ors.MoveFirst();
hmess.innerHTML = ors("TableFieldName");
ors.Close();
oconn.Close();

Thank you for the answers and your help.

