How to operate Mysql database instances in JavaScript

Source: Internet
Author: User
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 {//}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.