access|javascript| Data | Database file composition:
The Access database is named Mydata.mdb, and a table named Count is built inside the table, which consists of two
Field consists of: ID and Count, and a table with data: (' count ', ' 100 ').
The text file is named Count.txt, and a number is written inside.
The static page name is cnt.htm.
All 3 files are placed in the same directory.
Because it takes an Access database and it takes a non-standard SQL syntax, be aware that the table name
and field names need to be added square brackets: []
Here is the code in the page:
Where the Getcountfromdb method is to manipulate the Access database, Getcountfromtxt
The method is to operate on txt plain text, both of which are executed locally.
<! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 transitional//en" >
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<meta name= "generator" content= "EditPlus" >
<meta name= "Author" content= "" >
<meta name= "Keywords" content= "" >
<meta name= "Description" content= "" >
<script language= "JavaScript" >
<!--
function Getcountfromdb () {
Based on the current paging file, locate the absolute path where the file is located.
var filePath = location.href.substring (0, Location.href.indexOf ("cnt.htm"));
var path = FilePath + "Mydata.mdb";
Remove the 8 characters from the first "files://" in the string.
Path = path.substring (8);
var updatecnt = 0;
The SQL statement that is used to generate the query and update.
var sqlselcnt = "SELECT count from [Count] WHERE ID = ' count '";
var sqlupdcnt = "UPDATE [Count] SET [count] = '";
Establish a connection and generate a related string
www.zhangpeng.com.cn。
var con = new ActiveXObject ("ADODB.") Connection ");
Con. Provider = "Microsoft.Jet.OLEDB.4.0";
Con. ConnectionString = "Data source=" + path;
Con.open;
var rs = new ActiveXObject ("ADODB. Recordset ");
Rs.Open (sqlselcnt, con);
while (!rs.eof) {
var cnt = Rs. Fields ("COUNT");
document.write (CNT);
The database will be updated after the results are obtained plus 1.
UPDATECNT = CNT * 1 + 1;
Rs.movenext;
}
Rs.close ();
rs = null;
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