Home > Web Front-end > JS Tutorial > body text

How to implement addition, deletion, modification and query of database in js_javascript skills

WBOY
Release: 2016-05-16 17:48:07
Original
1642 people have browsed it

JavaScript operates the database and JS operates the Access database, which is similar to other language operations. I have summarized the custom codes for reference only.
Now there is a file abc.mdf in the F drive, the table name is Student, there are 2 fields in total, Id numeric type primary key, stuName text type, now add, delete, modify and check the table:
1. Query

Copy code The code is as follows:



Data Query




< /HTML>

2. Add operation
Copy code The code is as follows:



Add operation










< td>

Number





3. Delete Operation
Copy code The code is as follows:



Delete operation





4. Modification operation
Copy code The code is as follows:



修改操作

<script> <br>function updateUser(userId,userName) <br>{ <br>var conn = new ActiveXObject("ADODB.Connection"); <br>conn.Open("DBQ=F://abc.mdb;DRIVER={Microsoft Access Driver (*.mdb)};"); <br>var rs = new ActiveXObject("ADODB.Recordset"); <br>var sql="update Student set stuName='" userName "' where Id=" userId ""; <br>conn.execute(sql); <br>conn.close(); <br>conn = null; <br>alert("修改成功"); <br>} <br></script>










编号 姓名





另外,JS也可以操作SQL Server数据库
数据库名为:MySchool,表名为Student,StudentId为int类型,自增列,studentName为学生姓名,为varchar类型。数据库用户名为sa,密码是ok,
复制代码 代码如下:



SQL数据查询





source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!