BLOG from Great_Domino
File composition: Access database name is MyData.mdb, built a table named count, the table consists of two fields: ID and count, there is a data in the table: ('count', '100'). The text file is named count.txt, which is just written to a number. The static page name is CNT.HTM. All three files are placed in the same directory. Because of the Access database, it uses non-standard SQL syntax, so pay attention to the table name and field names need to add brackets: [] The following is the code in the page: where the getCountFromDB method is to operate the Access database, the getCountFromTXT method is TXT plain text is operated, both of which are passed locally.
VAR Con = New ActiveXObject ("AdoDb.connection"); con.Provider = "microsoft.jet.OleDb.4.0"; con.connectionstring = "data source =" path; con.open; var = new activXObject (" AdoDb.recordset "); rs.open (SqlSelcnt, con); while (! Rs.eof) {var cnt = rs.fields (" count "); document.write (cnt); // will get the result plus 1 Update the database. Updatecnt = cnt * 1 1; rs.movenext;} r = NULL; SQLUPDCNT = SQLUPDCNT UPDATECNT "CON.EXECUTE (SQLUPDCNT); con.close (); con = null; } Function getCountFromtxt () {var filepath = location.href.substring (0, location.href.indexof ("cnt.htm")); var path = filepath "count.txt"; Path = path.substring (8) VAR nextcnt = 0; VAR FSO, F1, TS, S; // Open the text file in a read-only mode. Var forreading = 1; // Opens the text file in the read and write mode. Var forwriting = 2; fso = new activiXObject ("scripting.filesystemObject"); f1 = fso.getfile (path); ts = f1.openastextStream (forreading, true); s = ts.readline (); nextcnt = evAl (S ) 1; Document.write ("now count is:" s); ts.close (); ts = f1.openastextStream (forwriting, true); ts.writeline (NEXTCNT); ts.close ();} / / -> script> head>