This article mainly introduces how to operate Mysql database instances in JavaScript. This article provides the implementation code directly. the code contains detailed comments. For more information, see
// Create a database connection object var conn = new ActiveXObject ("ADODB. connection "); // Create a dataset object var rs = new ActiveXObject (" ADODB. recordset "); try {// Database connection string. for detailed configuration, see connectionstring =" Driver = {MySQL ODBC 5.2 w Driver}; Server = localhost; Database = myDataBase; user = myUsername; Password = myPassword; Option = 3; Port = 3306 "; // open the connection conn. open (connectionstring); // query statement var SQL = "select * from tb_col"; // open the dataset (that is, execute the query syntax rs.open( SQL ,conn=((~rs=conn.exe cute (SQL);) // traverse all the records while (! Rs. eof) {// WScript is the host object of the Windows Script. for details, see windows help. // WScript. echo output record content WScript. echo (rs. fields ("id") + "\ t" + rs. fields ("name") + "\ n"); // The next record rs. moveNext ();} // closes the record set rs. close (); // close the database connection conn. close ();} catch (e) {// WScript for exception reporting. echo (e. message);} finally {//}